人脸检测和属性Face detection and attributes

本文解释人脸检测和人脸属性数据的概念。This article explains the concepts of face detection and face attribute data. 人脸检测是在图像中查找人脸,并选择地返回不同类型人脸相关数据的操作。Face detection is the action of locating human faces in an image and optionally returning different kinds of face-related data.

可以使用人脸 - 检测操作在图像中检测人脸。You use the Face - Detect operation to detect faces in an image. 最起码,检测到的每个人脸对应于响应中的 faceRectangle 字段。At a minimum, each detected face corresponds to a faceRectangle field in the response. 这组像素坐标(左边缘、顶部、宽度、高度)标记所找到的人脸。This set of pixel coordinates for the left, top, width, and height mark the located face. 使用这些坐标可以获取人脸的位置及其大小。Using these coordinates, you can get the location of the face and its size. 在 API 响应中,人脸按照从大到小的顺序列出。In the API response, faces are listed in size order from largest to smallest.

人脸 IDFace ID

人脸 ID 是在图像中检测到的每个人脸的唯一标识符字符串。The face ID is a unique identifier string for each detected face in an image. 可以在人脸 - 检测 API 调用中请求人脸 ID。You can request a face ID in your Face - Detect API call.

人脸特征点Face landmarks

人脸特征点是人脸上的一组易于查找的点,例如瞳孔或鼻尖。Face landmarks are a set of easy-to-find points on a face, such as the pupils or the tip of the nose. 默认情况下,有 27 个预定义的特征点。By default, there are 27 predefined landmark points. 下图显示了所有 27 个点:The following figure shows all 27 points:

标有所有 27 个特征点的人脸插图

以像素为单位返回的点坐标。The coordinates of the points are returned in units of pixels.

属性Attributes

属性是可由人脸 - 检测 API 选择性地检测到的一组特征。Attributes are a set of features that can optionally be detected by the Face - Detect API. 以下属性可以检测到:The following attributes can be detected:

  • AgeAge. 特定人脸的估计年龄(岁)。The estimated age in years of a particular face.

  • BlurBlur. 图像中人脸的模糊度。The blurriness of the face in the image. 此属性返回 0 到 1 的值,以及非正式分级:low、medium 或 high。This attribute returns a value between zero and one and an informal rating of low, medium, or high.

  • EmotionEmotion. 给定人脸的情感列表及其检测置信度。A list of emotions with their detection confidence for the given face. 置信度分数会进行标准化,所有情感的分数加起来后得到一个总的分数。Confidence scores are normalized, and the scores across all emotions add up to one. 返回的情感包括快乐、悲伤、中性、愤怒、蔑视、厌恶、惊讶、恐惧。The emotions returned are happiness, sadness, neutral, anger, contempt, disgust, surprise, and fear.

  • ExposureExposure. 图像中人脸的曝光度。The exposure of the face in the image. 此属性返回 0 到 1 的值,以及非正式的分级:underExposure、goodExposure 或 overExposure。This attribute returns a value between zero and one and an informal rating of underExposure, goodExposure, or overExposure.

  • Facial hairFacial hair. 给定人脸的胡须状态和长度。The estimated facial hair presence and the length for the given face.

  • GenderGender. 给定人脸的估计性别。The estimated gender of the given face. 可能的值为 male、female 和 genderless。Possible values are male, female, and genderless.

  • GlassesGlasses. 给定的人脸是否戴有眼镜。Whether the given face has eyeglasses. 可能的值为 NoGlasses、ReadingGlasses、Sunglasses 和 Swimming Goggles。Possible values are NoGlasses, ReadingGlasses, Sunglasses, and Swimming Goggles.

  • HairHair. 人脸的发型。The hair type of the face. 此属性显示头发是否可见、是否检测到秃顶,以及检测到了哪种发色。This attribute shows whether the hair is visible, whether baldness is detected, and what hair colors are detected.

  • Head poseHead pose. 人脸在 3D 空间中的摆向。The face's orientation in 3D space. 此属性以俯仰角、翻滚角和偏航角(以度为单位)描述。This attribute is described by the pitch, roll, and yaw angles in degrees. 值的范围分别为 -90 度到 90 度、-180 度到 180 度,以及 -90 度到 90 度。The value ranges are -90 degrees to 90 degrees, -180 degrees to 180 degrees, and -90 degrees to 90 degrees, respectively. 有关角度映射,请参阅以下示意图:See the following diagram for angle mappings:

    标有俯仰、翻滚和偏航轴的头部

  • MakeupMakeup. 人脸是否有化妆。Whether the face has makeup. 此值返回 eyeMakeup 和 lipMakeup 的布尔值。This attribute returns a Boolean value for eyeMakeup and lipMakeup.

  • NoiseNoise. 在人脸图像中检测到的视觉噪点。The visual noise detected in the face image. 此属性返回 0 到 1 的值,以及非正式分级:low、medium 或 high。This attribute returns a value between zero and one and an informal rating of low, medium, or high.

  • OcclusionOcclusion. 是否存在遮挡人脸部位的物体。Whether there are objects blocking parts of the face. 此属性返回 eyeOccluded、foreheadOccluded 和 mouthOccluded 的布尔值。This attribute returns a Boolean value for eyeOccluded, foreheadOccluded, and mouthOccluded.

  • SmileSmile. 给定人脸的微笑表情。The smile expression of the given face. 此值介于 0(未微笑)与 1(明确的微笑)之间。This value is between zero for no smile and one for a clear smile.

Important

人脸属性是使用统计算法预测的,Face attributes are predicted through the use of statistical algorithms. 不一定准确。They might not always be accurate. 根据特性数据做出决策时请小心。Use caution when you make decisions based on attribute data.

输入数据Input data

使用以下提示来确保输入的图像提供最准确的检测结果:Use the following tips to make sure that your input images give the most accurate detection results:

  • 支持的输入图像格式为 JPEG、PNG、GIF(第一帧)和 BMP。The supported input image formats are JPEG, PNG, GIF for the first frame, and BMP.
  • 图像文件不得大于 4 MB。The image file size should be no larger than 4 MB.
  • 可检测的人脸大小范围为 36 x 36 到 4096 x 4096 像素。The detectable face size range is 36 x 36 to 4096 x 4096 pixels. 无法检测超出此范围的人脸。Faces outside of this range won't be detected.
  • 某些人脸会因技术难题而检测不到。Some faces might not be detected because of technical challenges. 极端的人脸角度(头部姿势)或人脸遮挡物(太阳镜或遮挡人脸部位的手等物体)可能会影响检测。Extreme face angles (head pose) or face occlusion (objects such as sunglasses or hands that block part of the face) can affect detection. 正面和接近正面的人脸可提供最佳结果。Frontal and near-frontal faces give the best results.

若要检测视频源中的人脸,则可通过调整视频摄像头上的某些设置来改进性能:If you're detecting faces from a video feed, you may be able to improve performance by adjusting certain settings on your video camera:

  • 平滑处理:许多视频摄像头应用平滑处理效果。Smoothing: Many video cameras apply a smoothing effect. 在可能的情况下,应将此关闭,因为它会在帧之间产生模糊,降低清晰度。You should turn this off if you can because it creates a blur between frames and reduces clarity.

  • 快门速度:更快的快门速度会减少帧之间的移动量,使每个帧更清晰。Shutter Speed: A faster shutter speed reduces the amount of motion between frames and makes each frame clearer. 建议将快门速度设置为 1/60 秒或更快。We recommend shutter speeds of 1/60 second or faster.

  • 快门角度:某些摄像头指定快门角度而不是快门速度。Shutter Angle: Some cameras specify shutter angle instead of shutter speed. 应该尽可能使用较低的快门角度。You should use a lower shutter angle if possible. 这会增加视频帧的清晰度。This will result in clearer video frames.

    Note

    摄像头的快门角度较低时,每个帧收到的光线较少,因此图像会更黑。A camera with a lower shutter angle will receive less light in each frame, so the image will be darker. 需确定适合使用的级别。You'll need to determine the right level to use.

后续步骤Next steps

熟悉人脸检测的概念后,接下来请了解如何编写一个可在给定图像中检测人脸的脚本。Now that you're familiar with face detection concepts, learn how to write a script that detects faces in a given image.