使用手冊
Print

檢查積木是否包含情感屬性

Face有情感屬性

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Azure_Face_hasEmotionAttribute\"><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_hasEmotionAttribute\"><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\">checkEmotionAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It has emotion attribute</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkEmotionAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It doesn't have emotion 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>checkEmotionAttribute</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://thumbs.dreamstime.com/b/portrait-happy-older-white-man-wearing-glasses-handsome-red-174874786.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\">checkEmotionAttribute</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_hasEmotionAttribute\"><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\">checkEmotionAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It has emotion attribute</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkEmotionAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It doesn't have emotion 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\">checkEmotionAttribute</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

當程式包含「檢測圖像中的人臉」積木,它便有情感屬性:

當程式包含「檢測圖像中的蒙面人臉」積木,它便沒有情感屬性: