User Manual
Print

Checking blocks contain Gender Attribute or Not

Face has gender attribute

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

This is used for checking whether the blocks contain gender attribute. 

Parameters: AI Result (Face Detection from Azure)
Output: Boolean (True/False)
Sample code:

It is using an if-else condition to check it contains gender attribute or not. 

				
					{"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_hasGenderAttribute\"><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\">checkGenderAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It has gender attribute.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkGenderAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It doesn't have gender 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>checkGenderAttribute</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_detectMaskedFaces\"><value name=\"img\"><block type=\"variables_get\"><field name=\"VAR\">image</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">checkGenderAttribute</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_hasGenderAttribute\"><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\">checkGenderAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It has gender attribute.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">checkGenderAttribute</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">It doesn't have gender 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\">checkGenderAttribute</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

When it contains “detect faces in image” block, it should have gender attribute 

When it contains “detect masked faces in image” block, it should have no gender attribute: