人脸识别的概念Face recognition concepts

本文解释“验证”、“查找相似人脸”、“分组”和“识别”人脸识别操作和底层数据结构的概念。This article explains the concepts of the Verify, Find Similar, Group, and Identify face recognition operations and the underlying data structures. 从广义上讲,识别描述的是比较两个不同的人脸,以确定它们是否相似或属于同一个人的工作流程。Broadly, recognition describes the work of comparing two different faces to determine if they're similar or belong to the same person.

识别操作主要使用以下数据结构。The recognition operations use mainly the following data structures. 这些对象存储在云中,可按其 ID 字符串引用。These objects are stored in the cloud and can be referenced by their ID strings. ID 字符串在订阅中始终唯一。ID strings are always unique within a subscription. 名称字段可以重复。Name fields can be duplicated.

名称Name 说明Description
DetectedFaceDetectedFace 此单个人脸表示形式通过人脸检测操作检索。This single face representation is retrieved by the face detection operation. 其 ID 在创建 24 小时后过期。Its ID expires 24 hours after it's created.
PersistedFacePersistedFace 将 DetectedFace 对象添加到某个组(例如 FaceList 或 Person)后,它们将变成 PersistedFace 对象。When DetectedFace objects are added to a group, such as FaceList or Person, they become PersistedFace objects. 它们可以随时检索,且不会过期。They can be retrieved at any time and don't expire.
FaceListLargeFaceListFaceList or LargeFaceList 此数据结构是 PersistedFace 对象的分类列表。This data structure is an assorted list of PersistedFace objects. FaceList 具有唯一的 ID、名称字符串,以及(可选的)用户数据字符串。A FaceList has a unique ID, a name string, and optionally a user data string.
PersonPerson 此数据结构是属于同一个人的 PersistedFace 对象列表。This data structure is a list of PersistedFace objects that belong to the same person. 它具有唯一的 ID、名称字符串,以及(可选的)用户数据字符串。It has a unique ID, a name string, and optionally a user data string.
PersonGroupLargePersonGroupPersonGroup or LargePersonGroup 此数据结构是 Person 对象的分类列表。This data structure is an assorted list of Person objects. 它具有唯一的 ID、名称字符串,以及(可选的)用户数据字符串。It has a unique ID, a name string, and optionally a user data string. PersonGroup 必须事先经过训练才能在识别操作中使用。A PersonGroup must be trained before it can be used in recognition operations.

识别操作Recognition operations

本部分详细说明四项识别操作如何使用上述数据结构。This section details how the four recognition operations use the data structures previously described. 概述中详细介绍了每项识别操作。For a broad description of each recognition operation, see Overview.

VerifyVerify

验证操作采用人脸 ID(来自 DetectedFace 或 PersistedFace)以及另一个人脸 ID 或 Person 对象,并确定它们是否属于同一个人。The Verify operation takes a face ID from DetectedFace or PersistedFace and either another face ID or a Person object and determines whether they belong to the same person. 如果传入了 Person 对象,可以选择性地传入该 Person 所属的 PersonGroup 以提高性能。If you pass in a Person object, you can optionally pass in a PersonGroup to which that Person belongs to improve performance.

查找相似Find Similar

查找相似人脸操作采用人脸 ID(来自 DetectedFace 或 PersistedFace)以及 FaceList 或其他人脸 ID 的数组。The Find Similar operation takes a face ID from DetectedFace or PersistedFace and either a FaceList or an array of other face IDs. 使用 FaceList 时,它会返回与给定人脸相似的人脸的较小 FaceList。With a FaceList, it returns a smaller FaceList of faces that are similar to the given face. 使用人脸 ID 的数组时,它同样会返回较小的数组。With an array of face IDs, it similarly returns a smaller array.

Group

分组操作采用分类人脸 ID(来自 DetectedFace 或 PersistedFace)的数组,并返回分组为多个较小数组的相同 ID。The Group operation takes an array of assorted face IDs from DetectedFace or PersistedFace and returns the same IDs grouped into several smaller arrays. 每个“groups”数组包含看上去相似的人脸 ID。Each "groups" array contains face IDs that appear similar. 单个“messyGroup”数组包含未找到相似性的人脸 ID。A single "messyGroup" array contains face IDs for which no similarities were found.

识别Identify

识别操作采用一个或多个人脸 ID(来自 DetectedFace 或 PersistedFace)和一个 PersonGroup,并返回每张人脸可能属于的 Person 对象列表。The Identify operation takes one or several face IDs from DetectedFace or PersistedFace and a PersonGroup and returns a list of Person objects that each face might belong to. 返回的 Person 对象包装为具有预测置信度值的 Candidate 对象。Returned Person objects are wrapped as Candidate objects, which have a prediction confidence value.

输入数据Input data

使用以下提示来确保输入的图像提供最准确的识别结果:Use the following tips to ensure that your input images give the most accurate recognition results:

  • 支持的输入图像格式为 JPEG、PNG、GIF(第一帧)和 BMP。The supported input image formats are JPEG, PNG, GIF (the first frame), BMP.
  • 图像文件不得大于 6 MB。Image file size should be no larger than 6 MB.
  • 创建 Person 对象时,请使用具有不同类型的角度和照明效果的照片。When you create Person objects, use photos that feature different kinds of angles and lighting.
  • 某些人脸会因技术难题而识别不到,例如:Some faces might not be recognized because of technical challenges, such as:
    • 具有极端照明(例如严重的背光)的图像。Images with extreme lighting, for example, severe backlighting.
    • 有障碍物挡住了一只或两只眼睛。Obstructions that block one or both eyes.
    • 发型或胡须的差异。Differences in hair type or facial hair.
    • 年龄使面貌发生变化。Changes in facial appearance because of age.
    • 极端的面部表情。Extreme facial expressions.

后续步骤Next steps

熟悉人脸识别的概念后,接下来请编写一个可以针对训练的 PersonGroup 识别人脸的脚本。Now that you're familiar with face recognition concepts, Write a script that identifies faces against a trained PersonGroup.