使用手册
Print

检查积木是否包含蒙面属性

Face有蒙面属性

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Azure_Face_hasMaskAttribute\"><value name=\"face\"><block type=\"variables_get\"><field name=\"VAR\">face</field></block></value></block></xml>"}
				
			

这积木是用作检查积木是否包含蒙面属性。

参数:人工智能结果(Azure蒙面人脸检测)

输出:布林值(True/False)

示例代码:

这程式使用了一个if-else条件式来检查它是否有蒙面属性。

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"controls_if\"><mutation else=\"1\"/><value name=\"IF0\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></shadow><block type=\"Azure_Face_hasMaskAttribute\"><value name=\"face\"><block type=\"lists_index_get\"><value name=\"LIST\"><block type=\"Azure_FaceDetectionResult_getFaces\"><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">result</field></block></value></block></value><value name=\"INDEX\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value></block></value></block></value><statement name=\"DO0\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkMaskAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It has mask attribute.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkMaskAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It doesn't have mask attribute.</field></shadow></value></block></statement></block></xml>"}
				
			
				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>mainLayout</variable><variable>mainScreen</variable><variable>image</variable><variable>result</variable><variable>checkMaskAttribute</variable><variable>face</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">image</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Download_image\"><value name=\"url\"><shadow type=\"text\"><field name=\"TEXT\">https://assets.entrepreneur.com/content/3x2/2000/20190502194704-ent19-june-editorsnote.jpeg</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">result</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Azure_detectFaces\"><value name=\"img\"><block type=\"variables_get\"><field name=\"VAR\">image</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">checkMaskAttribute</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"0\" _input_init=\"false\"></mutation></block></value><next><block type=\"controls_if\"><mutation else=\"1\"/><value name=\"IF0\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></shadow><block type=\"Azure_Face_hasMaskAttribute\"><value name=\"face\"><block type=\"lists_index_get\"><value name=\"LIST\"><block type=\"Azure_FaceDetectionResult_getFaces\"><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">result</field></block></value></block></value><value name=\"INDEX\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value></block></value></block></value><statement name=\"DO0\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkMaskAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It has mask attribute.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkMaskAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It doesn't have mask attribute.</field></shadow></value></block></statement><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"variables_get\"><field name=\"VAR\">checkMaskAttribute</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

当它包含「检测图像中的蒙面人脸」,它应该有蒙面属性:

当它包含「检测图像中的人脸」,它应该没有蒙面属性: