User Manual
Print

Counting Number of Faces Within a Range of Aged

Face Detection Result count faces aged

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo1</variable><variable>photo2</variable><variable>faceDetectionResult1</variable><variable>faceDetectionResult2</variable><variable>faceVerificationResult</variable><variable>faceDetectionResult</variable></variables><block type=\"UnaAI_FaceDetectionResult_countAge\" disabled=\"true\" x=\"-22\" y=\"337\"><field name=\"operator\">ConditionalOperator.EqualTo</field><value name=\"faceDetectionResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceDetectionResult</field></block></value><value name=\"age\"><shadow type=\"math_number\" disabled=\"true\"><field name=\"NUM\">0</field></shadow></value></block></xml>"}
				
			

This block is used for counting the total number of face when it is within the age range.

Parameters:

      • AI Result (Face Detection from Azure)
      • Condition:
            1. Operator: =(Default)/≠/</≤/>/≥
            2. Number (Default: 0)

Output: AI Result
Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">photo</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Resources_getPhotoByURL\"><value name=\"url\"><shadow type=\"text\"><field name=\"TEXT\">https://www.magicubedu.com/una/AI5/samples/man1.jpg</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">faceDetectionResult</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"UnaAI_detectFaces\"><value name=\"img\"><block type=\"variables_get\"><field name=\"VAR\">photo</field></block></value></block></value><next><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"UnaAI_FaceDetectionResult_countAge\"><field name=\"operator\">ConditionalOperator.EqualTo</field><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value><value name=\"age\"><shadow type=\"math_number\"><field name=\"NUM\">32</field></shadow></value></block></value><next><block type=\"UnaAI_FaceDetectionResult_markFaces\"><field name=\"attribute\">FaceAttribute.Age</field><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

The output:

Face Detection Result Count Faces Aged - Output