使用手册
Print

检查积木是否包含眼镜属性

Face有眼镜属性

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Azure_Face_hasGlassesAttribute\"><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_hasGlassesAttribute\"><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\">checkGlassesAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It has glasses attribute.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkGlassesAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It doesn't have glasses 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>checkGlassesAttribute</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://image.shutterstock.com/image-photo/2-people-protective-masks-walking-260nw-1781747534.jpg</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\">checkGlassesAttribute</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_hasGlassesAttribute\"><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\">checkGlassesAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It has glasses attribute.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkGlassesAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It doesn't have glasses 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\">checkGlassesAttribute</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

将结果设为「检测图像中的人脸」时,它便包含眼镜属性:

将结果设为「检测图像中的蒙面人脸」时,它便不包含眼镜属性: