該文件詳細介紹了UnaAI的功能,包括顯示AI結果、物體和人臉檢測、人臉比對,以及根據髮色、眼鏡、性別和情緒等屬性識別人物。
常見
顯示 AI 結果
列印 AI 結果
{"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>"}
這用於在 AI 載入圖像或照片後顯示 AI 結果。
參數: AI Result (from Azure)
輸出: Json Value
示例代碼:
{"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>"}
輸出:


接收 AI 結果並將其更改為 JsonValue
將 AI 結果獲取為 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>"}
這用於在 AI 獲取照片中的物件或面部並將其轉換為 JSON 值後獲取 AI 結果。
參數: AI Result (from Azure)
輸出: Json Value
示例代碼:
{"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>"}
輸出:


物件檢測
照片內部的物體檢測
檢測照片中的物件
{"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>"}
這用於檢測圖像或照片中的物體。
參數: 相片
輸出: Json Value
示例代碼:
{"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>"}
輸出:


檢查物件檢測,包括關鍵字
視覺分析結果包含
{"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>"}
這用於檢查物件是否包含特定術語。
參數:
- AI結果(來自Azure的物體檢測)
- 顯示設置:字串
輸出: 布爾值(True/False)
示例代碼:
{"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>"}
輸出:

將物體檢測結果放入圖像中
視覺分析結果在照片上標記物體
{"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>"}
這用於標記照片內的邊界框。
參數:AI結果(來自Azure的物體檢測)
輸出: 照片
示例代碼:
{"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>"}
輸出:

人臉檢測和驗證
使用相似度信任值進行人臉比對
驗證並具有相同的面孔
{"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>"}
這用於識別兩張面孔之間的相似性置信度。
參數:AI結果(來自Azure的物體檢測)
輸出: Json Value
示例代碼:
{"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>"}
輸出:


照片中的人臉檢測
檢測照片中的人臉
{"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>"}
這用於檢測圖像或照片中的人臉。
參數: 相片
輸出: Json Value
示例代碼:
{"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>"}
輸出:



使用相似度信任值進行人臉比對
人臉驗證結果:獲得人臉相似度置信度
{"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>"}
這用於獲取兩張面孔相似度置信度。
參數: AI 結果(來自 Azure 的人臉檢測)
輸出: AI 結果
示例代碼:
{"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>"}
輸出:

計算年齡範圍內的人臉數量
人臉檢測結果 計數 人臉老化
{"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>"}
此塊用於計算年齡範圍內的人臉總數。
參數:
- AI 結果(來自 Azure 的人臉檢測)
- 條件:
- 運算子:=(預設)/≠/≤/>/≥
- 數字(預設值:0)
輸出: AI 結果
示例代碼:
{"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>"}
輸出:

計算人臉總數
人臉檢測結果 人臉計數
{"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>"}
這用於計算圖像中的人臉數量。
參數: AI 結果(來自 Azure 的人臉檢測)
輸出: AI 結果
示例代碼:
{"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>"}
輸出:

將人臉檢測結果放入圖像中
人臉檢測結果 用…在照片上
{"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>"}
此塊用於在圖像內顯示具有不同屬性的邊界框。
參數:
- AI 結果(來自 Azure 的人臉檢測)
- 條件:年齡(預設)/情感/性別/眼鏡類型/主要發色/微笑
輸出: 圖片
示例代碼:
{"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>"}
輸出:

更多 UnaAI
查找包含相關髮色的人
人臉檢測結果 計算頭髮顏色的人臉…
{"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>"}
尋找戴眼鏡的人
人臉檢測結果 計算戴眼鏡的人臉
{"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>"}
人臉檢測結果 計算男性的人臉
{"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>"}
這用於計算有多少人是男性/女性。
參數:
- AI 結果(來自 Azure 的人臉檢測)
- 顯示設置:公頭(預設)/母頭
輸出: 圖片
示例代碼:
{"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>"}
輸出:

尋找微笑的人
人臉檢測結果 計算帶笑容的面孔
{"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>"}
這用於計算有多少人在微笑。
參數: AI 結果(來自 Azure 的人臉檢測)
輸出: AI 結果
示例代碼:
{"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>"}
輸出:

尋找具有特定情感和價值的人
人臉檢測結果 計算帶有情緒的面孔 憤怒 值 > 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>"}
當人們有不同的情緒時,這用於計算面孔。
參數: AI 結果(來自 Azure 的人臉檢測)
條件:
- 憤怒(預設)/輕蔑/厭惡/恐懼/快樂/中性/悲傷/驚訝
- 數字(預設值:0)
輸出: AI 結果
示例代碼:
{"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>"}
輸出:

目録