您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

什么是 Azure 人脸 API?What is the Azure Face API?

Azure 认知服务人脸 API 提供用于检测、识别和分析图像中人脸的算法。The Azure Cognitive Services Face API provides algorithms that are used to detect, recognize, and analyze human faces in images. 在许多不同的软件方案中,处理人脸信息的功能非常重要。The ability to process human face information is important in many different software scenarios. 示例方案包括安全、自然用户界面、图像内容分析和管理、移动应用及机器人。Example scenarios are security, natural user interface, image content analysis and management, mobile apps, and robotics.

人脸 API 提供多个不同的函数。The Face API provides several different functions. 以下各部分将概述每个函数。Each function is outlined in the following sections. 请继续阅读以了解详细信息。Read on to learn more about them.

人脸检测Face detection

人脸 API 可以检测图像中的人脸,并返回其位置的矩形坐标。The Face API detects human faces in an image and returns the rectangle coordinates of their locations. (可选)人脸检测可以提取一系列人脸相关的属性。Optionally, face detection can extract a series of face-related attributes. 示例包括头部姿势、性别、年龄、情感、胡须和眼镜。Examples are head pose, gender, age, emotion, facial hair, and glasses.

备注

也可以通过计算机视觉 API 使用人脸检测功能。The face detection feature is also available through the Computer Vision API. 若要对人脸数据执行进一步的操作,请使用本文所述的人脸 API 服务。If you want to do further operations with face data, use the Face API, which is the service discussed in this article.

一位女士和一位男士的图像,在其面部绘制了矩形并显示了年龄和性别

有关人脸检测的详细信息,请参阅人脸检测概念文章。For more information on face detection, see the Face detection concepts article. 另请参阅检测 API 参考文档。Also see the Detect API reference documentation.

人脸验证Face verification

验证 API 针对检测到的两个人脸执行身份验证,或由一个检测到的人脸对一个人员对象执行身份验证。The Verify API performs an authentication against two detected faces or from one detected face to one person object. 实际上,它会评估两张脸是否属于同一个人。Practically, it evaluates whether two faces belong to the same person. 此功能可能适用于安全方案。This capability is potentially useful in security scenarios. 有关详细信息,请参阅人脸识别概念指南或验证 API 参考文档。For more information, see the Face recognition concepts guide or the Verify API reference documentation.

查找相似人脸Find similar faces

查找相似人脸 API 会将某个目标人脸与一组候选人脸进行比较,以查找与目标人脸相似的一小组人脸。The Find Similar API compares a target face with a set of candidate faces to find a smaller set of faces that look similar to the target face. 支持两种工作模式:matchPerson 和 matchFace。Two working modes, matchPerson and matchFace, are supported. 使用验证 API 针对同一人进行筛选后,matchPerson 模式会返回相似人脸。The matchPerson mode returns similar faces after it filters for the same person by using the Verify API. matchFace 模式会忽略相同人员筛选器。The matchFace mode ignores the same-person filter. 它返回相似候选人脸的列表,这些人脸不一定属于同一人。It returns a list of similar candidate faces that might or might not belong to the same person.

以下示例显示了目标人脸:The following example shows the target face:

一位微笑的女士

下面是候选人脸:And these are the candidate faces:

五位微笑的人的图像。

为了查找四张相似人脸,matchPerson 模式会返回 a 和 b,其中显示与目标人脸相同的人。To find four similar faces, the matchPerson mode returns a and b, which show the same person as the target face. matchFace 模式返回 a、b、c 和 d,恰好四个候选项,即使某些选项与目标不是同一人或者相似度低,也是如此。The matchFace mode returns a, b, c, and d, exactly four candidates, even if some aren't the same person as the target or have low similarity. 有关详细信息,请参阅人脸识别概念指南或查找相似人脸 API 参考文档。For more information, see the Face recognition concepts guide or the Find Similar API reference documentation.

人脸分组Face grouping

组 API 会基于相似性将未知人脸的集合分为几组。The Group API divides a set of unknown faces into several groups based on similarity. 每个组是原始人脸集合的互不相交真子集。Each group is a disjoint proper subset of the original set of faces. 一个组中的所有人脸可能属于同一人。All of the faces in a group are likely to belong to the same person. 一个人可能有多个不同的组。There can be several different groups for a single person. 组按其他因素(例如表情)区分。The groups are differentiated by another factor, such as expression, for example. 有关详细信息,请参阅人脸识别概念指南或分组 API 参考文档。For more information, see the Face recognition concepts guide or the Group API reference documentation.

人员识别Person identification

识别 API 用于根据人员数据库识别检测到的人脸。The Identify API is used to identify a detected face against a database of people. 此功能可用于照片管理软件中的自动图像标记。This feature might be useful for automatic image tagging in photo management software. 需提前创建数据库,以后可以不断地对其进行编辑。You create the database in advance, and you can edit it over time.

下图显示名为 "myfriends" 的数据库的示例。The following image shows an example of a database named "myfriends". 每个组最多可以包含 100 万个不同的 person 对象。Each group can contain up to 1 million different person objects. 每个人员对象可以注册最多 248 张人脸。Each person object can have up to 248 faces registered.

包含三个列(代表不同的人)的网格,每个列包含三行人脸图像

创建并训练数据库后,可以对组使用新检测到的人脸执行识别。After you create and train a database, you can perform identification against the group with a new detected face. 如果人脸被标识为组中的某一人员,则返回该人员对象。If the face is identified as a person in the group, the person object is returned.

有关人员识别的详细信息,请参阅人脸识别概念指南或识别 API 参考文档。For more information about person identification, see the Face recognition concepts guide or the Identify API reference documentation.

使用容器Use containers

将标准化的 Docker 容器安装到靠近数据的位置后,使用人脸容器来检测和识别人脸。Use the Face container to detect, recognize, and identify faces by installing a standardized Docker container closer to your data.

示例应用Sample apps

以下示例应用程序显示了人脸 API 的多种用法:The following sample applications show a few ways to use the Face API:

数据隐私和安全性Data privacy and security

与所有认知服务资源一样,使用人脸服务的开发人员必须了解 Microsoft 针对客户数据的政策。As with all of the Cognitive Services resources, developers who use the Face service must be aware of Microsoft's policies on customer data. 有关详细信息,请参阅 Microsoft 信任中心内的“认知服务”页For more information, see the Cognitive Services page on the Microsoft Trust Center.

后续步骤Next steps

遵循以下快速入门在代码中实现人脸检测方案:Follow a quickstart to implement a face-detection scenario in code: