This documentation details UnaAI functionalities, including displaying AI results, object and face detection, face comparison, and identifying people based on attributes like hair color, glasses, gender, and emotions.
Common
Display the AI Result
Print AI Result
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>result</variable></variables><block type=\"UnaAI_AiResult_showContent\" disabled=\"true\" x=\"113\" y=\"202\"><value name=\"result\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">result</field></block></value></block></xml>"}
This is used to show the AI result after the AI loaded the image or photo.
Parameters: AI Result (from Azure)
Output: Json Value
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</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/AI1/2.jpg</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">visionAnalysisResult</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"UnaAI_detectObjects\"><value name=\"img\"><block type=\"variables_get\"><field name=\"VAR\">photo</field></block></value></block></value><next><block type=\"UnaAI_AiResult_showContent\"><value name=\"result\"><block type=\"variables_get\"><field name=\"VAR\">visionAnalysisResult</field></block></value><next><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"variables_get\"><field name=\"VAR\">photo</field></block></value></block></next></block></next></block></next></block></statement></block></xml>"}
The output:
Receiving AI Result and Changing It to JsonValue
Get AI result as JsonValue
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</variable><variable>result</variable></variables><block type=\"UnaAI_AiResult_getContentAsJsonValue\" disabled=\"true\" x=\"113\" y=\"248\"><value name=\"result\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">result</field></block></value></block></xml>"}
This is used to get the AI result after AI get the object or face in photo and convert it to JSON value.
Parameters: AI Result (from Azure)
Output: Json Value
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</variable><variable>JsonValue</variable><variable>result</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/AI1/2.jpg</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">visionAnalysisResult</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"UnaAI_detectObjects\"><value name=\"img\"><block type=\"variables_get\"><field name=\"VAR\">photo</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">JsonValue</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"UnaAI_AiResult_getContentAsJsonValue\"><value name=\"result\"><block type=\"variables_get\"><field name=\"VAR\">visionAnalysisResult</field></block></value></block></value><next><block type=\"basic_consoleLogText\"><value name=\"text\"><block type=\"Json_JsonValue_stringify\"><value name=\"jsonValue\"><block type=\"variables_get\"><field name=\"VAR\">JsonValue</field></block></value></block></value><next><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"variables_get\"><field name=\"VAR\">photo</field></block></value></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
The output:
Object Detection
Object Detection Inside a Photo
Detect Objects in Photo
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</variable><variable>JsonValue</variable><variable>result</variable></variables><block type=\"UnaAI_detectObjects\" disabled=\"true\" x=\"248\" y=\"383\"/></xml>"}
This is used to detect the object inside the image or photo.
Parameters: Photo
Output: Json Value
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</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/AI1/2.jpg</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">visionAnalysisResult</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"UnaAI_detectObjects\"><value name=\"img\"><block type=\"variables_get\"><field name=\"VAR\">photo</field></block></value></block></value><next><block type=\"UnaAI_AiResult_showContent\"><value name=\"result\"><block type=\"variables_get\"><field name=\"VAR\">visionAnalysisResult</field></block></value><next><block type=\"UnaAI_VisionAnalysisResult_markObjects\"><value name=\"visionAnalysisResult\"><block type=\"variables_get\"><field name=\"VAR\">visionAnalysisResult</field></block></value></block></next></block></next></block></next></block></statement></block></xml>"}
The output:
Checking Object Detection Including Keyword
Vision Analysis Result Contains
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</variable></variables><block type=\"UnaAI_VisionAnalysisResult_hasObject\" disabled=\"true\" x=\"112\" y=\"337\"><value name=\"visionAnalysisResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">visionAnalysisResult</field></block></value><value name=\"objName\"><shadow type=\"text\" disabled=\"true\"><field name=\"TEXT\"/></shadow></value></block></xml>"}
This is used to check whether the object contains specific terms.
Parameters:
- AI Result (Object Detection from Azure)
- Display setting: String
Output: Boolean (True/False)
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</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/AI1/2.jpg</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">visionAnalysisResult</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"UnaAI_detectObjects\"><value name=\"img\"><block type=\"variables_get\"><field name=\"VAR\">photo</field></block></value></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=\"UnaAI_VisionAnalysisResult_hasObject\"><value name=\"visionAnalysisResult\"><block type=\"variables_get\"><field name=\"VAR\">visionAnalysisResult</field></block></value><value name=\"objName\"><shadow type=\"text\"><field name=\"TEXT\">Apple</field></shadow></value></block></value><statement name=\"DO0\"><block type=\"basic_consoleLogText\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">It is an apple.</field></shadow></value></block></statement><statement name=\"ELSE\"><block type=\"basic_consoleLogText\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">It is not an apple.</field></shadow></value></block></statement></block></next></block></next></block></statement></block></xml>"}
The output:
Putting Object Detection Result Inside Image
Vision Analysis Result mark objects on photo
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</variable></variables><block type=\"UnaAI_VisionAnalysisResult_hasObject\" disabled=\"true\" x=\"112\" y=\"337\"><value name=\"visionAnalysisResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">visionAnalysisResult</field></block></value><value name=\"objName\"><shadow type=\"text\" disabled=\"true\"><field name=\"TEXT\"/></shadow></value></block></xml>"}
This is used to mark the boundary box inside the photo.
Parameters: AI Result (Object Detection from Azure)
Output: Photo
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</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\">visionAnalysisResult</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"UnaAI_detectObjects\"><value name=\"img\"><block type=\"variables_get\"><field name=\"VAR\">photo</field></block></value></block></value><next><block type=\"UnaAI_VisionAnalysisResult_markObjects\"><value name=\"visionAnalysisResult\"><block type=\"variables_get\"><field name=\"VAR\">visionAnalysisResult</field></block></value></block></next></block></next></block></statement></block></xml>"}
The output:
Face Detection and Verification
Face Comparison Using Similarity Confidence
Verify and have the same face
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>visionAnalysisResult</variable></variables><block type=\"UnaAI_verifyFaces\" disabled=\"true\" x=\"0\" y=\"0\"/></xml>"}
This is used to identify the similarity confidence between two faces.
Parameters: AI Result (Object Detection from Azure)
Output: Json Value
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo1</variable><variable>photo2</variable><variable>faceDetectionResult1</variable><variable>faceDetectionResult2</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">photo1</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\">photo2</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/man2.jpg</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">faceDetectionResult1</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\">photo1</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">faceDetectionResult2</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\">photo2</field></block></value></block></value><next><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"variables_get\"><field name=\"VAR\">photo1</field></block></value><next><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"variables_get\"><field name=\"VAR\">photo2</field></block></value><next><block type=\"UnaAI_AiResult_showContent\"><value name=\"result\"><block type=\"UnaAI_verifyFaces\"><value name=\"face1\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult1</field></block></value><value name=\"face2\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult2</field></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
The output:
Face Detection Inside a Photo
Detect face in photo
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo1</variable><variable>photo2</variable><variable>faceDetectionResult1</variable><variable>faceDetectionResult2</variable></variables><block type=\"UnaAI_detectObjects\" disabled=\"true\" x=\"-22\" y=\"202\"/></xml>"}
This is used to detect the face inside the image or photo.
Parameters: Photo
Output: Json Value
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=\"UnaAI_AiResult_showContent\"><value name=\"result\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></next></block></next></block></statement></block></xml>"}
The output:
Face Comparison Using Similarity Confidence
Face Verification Result get face similarity confidence
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable><variable>photo1</variable><variable>photo2</variable><variable>faceDetectionResult1</variable><variable>faceDetectionResult2</variable><variable>faceVerificationResult</variable></variables><block type=\"UnaAI_FaceVerificationResult_getSimilarityConfidence\" disabled=\"true\" x=\"158\" y=\"337\"><value name=\"faceVerificationResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceVerificationResult</field></block></value></block></xml>"}
This is used for getting two faces similarity confidence.
Parameters: AI Result (Face Detection from Azure)
Output: AI Result
Sample code:
{"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></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">photo1</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\">photo2</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/man2.jpg</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">faceDetectionResult1</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\">photo1</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">faceDetectionResult2</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\">photo2</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">faceVerificationResult</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"UnaAI_verifyFaces\"><value name=\"face1\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult1</field></block></value><value name=\"face2\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult2</field></block></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\">faceDetectionResult1</field></block></value><next><block type=\"UnaAI_FaceDetectionResult_markFaces\"><field name=\"attribute\">FaceAttribute.Age</field><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult2</field></block></value><next><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"UnaAI_FaceVerificationResult_getSimilarityConfidence\"><value name=\"faceVerificationResult\"><block type=\"variables_get\"><field name=\"VAR\">faceVerificationResult</field></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
The output:
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:
- Operator: =(Default)/≠/</≤/>/≥
- 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:
Counting Total Amount of Faces
Face Detection Result count faces
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable><variable>photo1</variable><variable>photo2</variable><variable>faceDetectionResult1</variable><variable>faceDetectionResult2</variable><variable>faceVerificationResult</variable></variables><block type=\"UnaAI_FaceDetectionResult_count\" disabled=\"true\" x=\"-22\" y=\"382\"><value name=\"faceDetectionResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></xml>"}
This is used for counting faces in the image.
Parameters: AI Result (Face Detection from Azure)
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://static01.nyt.com/images/2019/10/02/video/02-still-for-america-room-loop/02-still-for-america-room-loop-superJumbo.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_count\"><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></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:
Putting Face Detection Result Inside Image
Face Detection Result mark face with … on photo
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable></variables><block type=\"UnaAI_FaceDetectionResult_markFaces\" disabled=\"true\" x=\"23\" y=\"113\"><field name=\"attribute\">FaceAttribute.Age</field><value name=\"faceDetectionResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></xml>"}
This block is used for displaying the boundary box with different attributes inside the image.
Parameters:
- AI Result (Face Detection from Azure)
- Condition: age (Default)/emotion/gender/glasses type/major hair color/smile
Output: Image
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=\"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></statement></block></xml>"}
The output:
More in UnaAI
Finding People that contain Related Hair Colors
Face Detection Result count faces with hair color in …
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable></variables><block type=\"UnaAI_FaceDetectionResult_countHairColor\" disabled=\"true\" x=\"67\" y=\"247\"><value name=\"faceDetectionResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceDetectionResult</field></block></value><value name=\"color\"><shadow type=\"text\" disabled=\"true\"><field name=\"TEXT\"/></shadow></value></block></xml>"}
Finding People that are Wearing Glasses
Face Detection Result count faces with glasses
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable></variables><block type=\"UnaAI_FaceDetectionResult_countGlasses\" disabled=\"true\" x=\"22\" y=\"203\"><value name=\"faceDetectionResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></xml>"}
Face Detection Result count faces of Male
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable></variables><block type=\"UnaAI_FaceDetectionResult_countGender\" disabled=\"true\" x=\"-22\" y=\"202\"><field name=\"gender\">Gender.M</field><value name=\"faceDetectionResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></xml>"}
This is used for counting how many people is male/female.
Parameters:
- AI Result (Face Detection from Azure)
- Display setting: Male (Default)/Female
Output: Image
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://pbs.twimg.com/media/CQG1slyWIAASBJX.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=\"UnaAI_FaceDetectionResult_markFaces\"><field name=\"attribute\">FaceAttribute.Gender</field><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value><next><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"UnaAI_FaceDetectionResult_countGender\"><field name=\"gender\">Gender.M</field><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}
The output:
Finding People that are Smiling
Face Detection Result count face with smile
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable></variables><block type=\"UnaAI_FaceDetectionResult_countSmile\" disabled=\"true\" x=\"-22\" y=\"292\"><value name=\"faceDetectionResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></xml>"}
This is used for counting how many people is smiling.
Parameters: AI Result (Face Detection from Azure)
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://s.wsj.net/public/resources/images/BN-IR696_smilep_P_20150601134828.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=\"UnaAI_FaceDetectionResult_markFaces\"><field name=\"attribute\">FaceAttribute.Smile</field><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value><next><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"UnaAI_FaceDetectionResult_countSmile\"><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}
The output:
Finding People with Specific Emotion and Value
Face Detection Result count face with emotion Anger valued > 0
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable></variables><block type=\"UnaAI_FaceDetectionResult_countEmotion\" disabled=\"true\" x=\"22\" y=\"248\"><field name=\"emotion\">Emotion.Anger</field><value name=\"faceDetectionResult\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">faceDetectionResult</field></block></value><value name=\"value\"><shadow type=\"math_number\" disabled=\"true\"><field name=\"NUM\">0</field></shadow></value></block></xml>"}
This is used for counting faces when people have different emotions.
Parameters: AI Result (Face Detection from Azure)
Condition:
- anger (Default)/contempt/disgust/fear/happiness/ neutral/sadness/surprise
- 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://liveboldandbloom.com/wp-content/uploads/2020/04/Untitled-design-14-1.png</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=\"UnaAI_FaceDetectionResult_markFaces\"><field name=\"attribute\">FaceAttribute.Emotion</field><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value><next><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"UnaAI_FaceDetectionResult_countEmotion\"><field name=\"emotion\">Emotion.Anger</field><value name=\"faceDetectionResult\"><block type=\"variables_get\"><field name=\"VAR\">faceDetectionResult</field></block></value><value name=\"value\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}
The output:
Table of Content