使用计算机视觉进行人脸检测Face detection with Computer Vision

计算机视觉可检测图像中的人脸,并为每个检测到的人脸生成年龄、性别和人脸边框。Computer Vision can detect human faces within an image and generate the age, gender, and rectangle for each detected face.

备注

Azure 人脸服务也提供此功能。This feature is also offered by the Azure Face service. 有关人脸分析(包括人脸识别和姿势检测)的详细信息,请参阅此替代方案。See this alternative for more detailed face analysis, including face identification and pose detection.

人脸检测示例Face detection examples

以下示例演示了计算机视觉为包含单个人脸的图像返回的 JSON 响应。The following example demonstrates the JSON response returned by Computer Vision for an image containing a single human face.

视觉分析屋顶的女人人脸

{
    "faces": [
        {
            "age": 23,
            "gender": "Female",
            "faceRectangle": {
                "top": 45,
                "left": 194,
                "width": 44,
                "height": 44
            }
        }
    ],
    "requestId": "8439ba87-de65-441b-a0f1-c85913157ecd",
    "metadata": {
        "height": 200,
        "width": 300,
        "format": "Png"
    }
}

第二个示例演示了为包含多个人脸的图像返回的 JSON 响应。The next example demonstrates the JSON response returned for an image containing multiple human faces.

视觉分析家庭照片中的人脸

{
    "faces": [
        {
            "age": 11,
            "gender": "Male",
            "faceRectangle": {
                "top": 62,
                "left": 22,
                "width": 45,
                "height": 45
            }
        },
        {
            "age": 11,
            "gender": "Female",
            "faceRectangle": {
                "top": 127,
                "left": 240,
                "width": 42,
                "height": 42
            }
        },
        {
            "age": 37,
            "gender": "Female",
            "faceRectangle": {
                "top": 55,
                "left": 200,
                "width": 41,
                "height": 41
            }
        },
        {
            "age": 41,
            "gender": "Male",
            "faceRectangle": {
                "top": 45,
                "left": 103,
                "width": 39,
                "height": 39
            }
        }
    ],
    "requestId": "3a383cbe-1a05-4104-9ce7-1b5cf352b239",
    "metadata": {
        "height": 230,
        "width": 300,
        "format": "Png"
    }
}

后续步骤Next steps

有关如何使用人脸检测功能的详细信息,请参阅分析图像参考文档。See the Analyze Image reference documentation to learn more about how to use the face detection feature.