2019/11/22 - Amazon Rekognition - 3 updated api methods
Changes This release adds enhanced face filtering support to the IndexFaces API operation, and introduces face filtering for CompareFaces and SearchFacesByImage API operations.
{'QualityFilter': 'NONE | AUTO | LOW | MEDIUM | HIGH'}
Compares a face in the source input image with each of the 100 largest faces detected in the target input image.
Note
If the source image contains multiple faces, the service detects the largest face and compares it with each face detected in the target image.
You pass the input and target images either as base64-encoded image bytes or as references to images in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes isn't supported. The image must be formatted as a PNG or JPEG file.
In response, the operation returns an array of face matches ordered by similarity score in descending order. For each face match, the response provides a bounding box of the face, facial landmarks, pose details (pitch, role, and yaw), quality (brightness and sharpness), and confidence value (indicating the level of confidence that the bounding box contains a face). The response also provides a similarity score, which indicates how closely the faces match.
Note
By default, only faces with a similarity score of greater than or equal to 80% are returned in the response. You can change this value by specifying the SimilarityThreshold parameter.
CompareFaces also returns an array of faces that don't match the source image. For each face, it returns a bounding box, confidence value, landmarks, pose details, and quality. The response also returns information about the face in the source image, including the bounding box of the face and confidence value.
The QualityFilter input parameter allows you to filter out detected faces that don’t meet a required quality bar. The quality bar is based on a variety of common use cases. By default, CompareFaces chooses the quality bar that's used to filter faces. You can also explicitly choose the quality bar. Use QualityFilter , to set the quality bar by specifying LOW , MEDIUM , or HIGH . If you do not want to filter detected faces, specify NONE .
Note
To use quality filtering, you need a collection associated with version 3 of the face model or higher. To get the version of the face model associated with a collection, call DescribeCollection .
If the image doesn't contain Exif metadata, CompareFaces returns orientation information for the source and target images. Use these values to display the images with the correct image orientation.
If no faces are detected in the source or target images, CompareFaces returns an InvalidParameterException error.
Note
This is a stateless API operation. That is, data returned by this operation doesn't persist.
For an example, see Comparing Faces in Images in the Amazon Rekognition Developer Guide.
This operation requires permissions to perform the rekognition:CompareFaces action.
See also: AWS API Documentation
Request Syntax
client.compare_faces( SourceImage={ 'Bytes': b'bytes', 'S3Object': { 'Bucket': 'string', 'Name': 'string', 'Version': 'string' } }, TargetImage={ 'Bytes': b'bytes', 'S3Object': { 'Bucket': 'string', 'Name': 'string', 'Version': 'string' } }, SimilarityThreshold=..., QualityFilter='NONE'|'AUTO'|'LOW'|'MEDIUM'|'HIGH' )
dict
[REQUIRED]
The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing base64-encoded image bytes is not supported.
If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the Bytes field. For more information, see Images in the Amazon Rekognition developer guide.
Bytes (bytes) --
Blob of image bytes up to 5 MBs.
S3Object (dict) --
Identifies an S3 object as the image source.
Bucket (string) --
Name of the S3 bucket.
Name (string) --
S3 object key name.
Version (string) --
If the bucket is versioning enabled, you can specify the object version.
dict
[REQUIRED]
The target image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing base64-encoded image bytes is not supported.
If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the Bytes field. For more information, see Images in the Amazon Rekognition developer guide.
Bytes (bytes) --
Blob of image bytes up to 5 MBs.
S3Object (dict) --
Identifies an S3 object as the image source.
Bucket (string) --
Name of the S3 bucket.
Name (string) --
S3 object key name.
Version (string) --
If the bucket is versioning enabled, you can specify the object version.
float
The minimum level of confidence in the face matches that a match must meet to be included in the FaceMatches array.
string
A filter that specifies a quality bar for how much filtering is done to identify faces. Filtered faces aren't compared. If you specify AUTO , Amazon Rekognition chooses the quality bar. If you specify LOW , MEDIUM , or HIGH , filtering removes all faces that don’t meet the chosen quality bar. The default value is AUTO . The quality bar is based on a variety of common use cases. Low-quality detections can occur for a number of reasons. Some examples are an object that's misidentified as a face, a face that's too blurry, or a face with a pose that's too extreme to use. If you specify NONE , no filtering is performed.
To use quality filtering, the collection you are using must be associated with version 3 of the face model or higher.
dict
Response Syntax
{ 'SourceImageFace': { 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'Confidence': ... }, 'FaceMatches': [ { 'Similarity': ..., 'Face': { 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'Confidence': ..., 'Landmarks': [ { 'Type': 'eyeLeft'|'eyeRight'|'nose'|'mouthLeft'|'mouthRight'|'leftEyeBrowLeft'|'leftEyeBrowRight'|'leftEyeBrowUp'|'rightEyeBrowLeft'|'rightEyeBrowRight'|'rightEyeBrowUp'|'leftEyeLeft'|'leftEyeRight'|'leftEyeUp'|'leftEyeDown'|'rightEyeLeft'|'rightEyeRight'|'rightEyeUp'|'rightEyeDown'|'noseLeft'|'noseRight'|'mouthUp'|'mouthDown'|'leftPupil'|'rightPupil'|'upperJawlineLeft'|'midJawlineLeft'|'chinBottom'|'midJawlineRight'|'upperJawlineRight', 'X': ..., 'Y': ... }, ], 'Pose': { 'Roll': ..., 'Yaw': ..., 'Pitch': ... }, 'Quality': { 'Brightness': ..., 'Sharpness': ... } } }, ], 'UnmatchedFaces': [ { 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'Confidence': ..., 'Landmarks': [ { 'Type': 'eyeLeft'|'eyeRight'|'nose'|'mouthLeft'|'mouthRight'|'leftEyeBrowLeft'|'leftEyeBrowRight'|'leftEyeBrowUp'|'rightEyeBrowLeft'|'rightEyeBrowRight'|'rightEyeBrowUp'|'leftEyeLeft'|'leftEyeRight'|'leftEyeUp'|'leftEyeDown'|'rightEyeLeft'|'rightEyeRight'|'rightEyeUp'|'rightEyeDown'|'noseLeft'|'noseRight'|'mouthUp'|'mouthDown'|'leftPupil'|'rightPupil'|'upperJawlineLeft'|'midJawlineLeft'|'chinBottom'|'midJawlineRight'|'upperJawlineRight', 'X': ..., 'Y': ... }, ], 'Pose': { 'Roll': ..., 'Yaw': ..., 'Pitch': ... }, 'Quality': { 'Brightness': ..., 'Sharpness': ... } }, ], 'SourceImageOrientationCorrection': 'ROTATE_0'|'ROTATE_90'|'ROTATE_180'|'ROTATE_270', 'TargetImageOrientationCorrection': 'ROTATE_0'|'ROTATE_90'|'ROTATE_180'|'ROTATE_270' }
Response Structure
(dict) --
SourceImageFace (dict) --
The face in the source image that was used for comparison.
BoundingBox (dict) --
Bounding box of the face.
Width (float) --
Width of the bounding box as a ratio of the overall image width.
Height (float) --
Height of the bounding box as a ratio of the overall image height.
Left (float) --
Left coordinate of the bounding box as a ratio of overall image width.
Top (float) --
Top coordinate of the bounding box as a ratio of overall image height.
Confidence (float) --
Confidence level that the selected bounding box contains a face.
FaceMatches (list) --
An array of faces in the target image that match the source image face. Each CompareFacesMatch object provides the bounding box, the confidence level that the bounding box contains a face, and the similarity score for the face in the bounding box and the face in the source image.
(dict) --
Provides information about a face in a target image that matches the source image face analyzed by CompareFaces . The Face property contains the bounding box of the face in the target image. The Similarity property is the confidence that the source image face matches the face in the bounding box.
Similarity (float) --
Level of confidence that the faces match.
Face (dict) --
Provides face metadata (bounding box and confidence that the bounding box actually contains a face).
BoundingBox (dict) --
Bounding box of the face.
Width (float) --
Width of the bounding box as a ratio of the overall image width.
Height (float) --
Height of the bounding box as a ratio of the overall image height.
Left (float) --
Left coordinate of the bounding box as a ratio of overall image width.
Top (float) --
Top coordinate of the bounding box as a ratio of overall image height.
Confidence (float) --
Level of confidence that what the bounding box contains is a face.
Landmarks (list) --
An array of facial landmarks.
(dict) --
Indicates the location of the landmark on the face.
Type (string) --
Type of landmark.
X (float) --
The x-coordinate from the top left of the landmark expressed as the ratio of the width of the image. For example, if the image is 700 x 200 and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.
Y (float) --
The y-coordinate from the top left of the landmark expressed as the ratio of the height of the image. For example, if the image is 700 x 200 and the y-coordinate of the landmark is at 100 pixels, this value is 0.5.
Pose (dict) --
Indicates the pose of the face as determined by its pitch, roll, and yaw.
Roll (float) --
Value representing the face rotation on the roll axis.
Yaw (float) --
Value representing the face rotation on the yaw axis.
Pitch (float) --
Value representing the face rotation on the pitch axis.
Quality (dict) --
Identifies face image brightness and sharpness.
Brightness (float) --
Value representing brightness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a brighter face image.
Sharpness (float) --
Value representing sharpness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a sharper face image.
UnmatchedFaces (list) --
An array of faces in the target image that did not match the source image face.
(dict) --
Provides face metadata for target image faces that are analyzed by CompareFaces and RecognizeCelebrities .
BoundingBox (dict) --
Bounding box of the face.
Width (float) --
Width of the bounding box as a ratio of the overall image width.
Height (float) --
Height of the bounding box as a ratio of the overall image height.
Left (float) --
Left coordinate of the bounding box as a ratio of overall image width.
Top (float) --
Top coordinate of the bounding box as a ratio of overall image height.
Confidence (float) --
Level of confidence that what the bounding box contains is a face.
Landmarks (list) --
An array of facial landmarks.
(dict) --
Indicates the location of the landmark on the face.
Type (string) --
Type of landmark.
X (float) --
The x-coordinate from the top left of the landmark expressed as the ratio of the width of the image. For example, if the image is 700 x 200 and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.
Y (float) --
The y-coordinate from the top left of the landmark expressed as the ratio of the height of the image. For example, if the image is 700 x 200 and the y-coordinate of the landmark is at 100 pixels, this value is 0.5.
Pose (dict) --
Indicates the pose of the face as determined by its pitch, roll, and yaw.
Roll (float) --
Value representing the face rotation on the roll axis.
Yaw (float) --
Value representing the face rotation on the yaw axis.
Pitch (float) --
Value representing the face rotation on the pitch axis.
Quality (dict) --
Identifies face image brightness and sharpness.
Brightness (float) --
Value representing brightness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a brighter face image.
Sharpness (float) --
Value representing sharpness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a sharper face image.
SourceImageOrientationCorrection (string) --
The value of SourceImageOrientationCorrection is always null.
If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata that includes the image's orientation. Amazon Rekognition uses this orientation information to perform image correction. The bounding box coordinates are translated to represent object locations after the orientation information in the Exif metadata is used to correct the image orientation. Images in .png format don't contain Exif metadata.
Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without orientation information in the image Exif metadata. The bounding box coordinates aren't translated and represent the object locations before the image is rotated.
TargetImageOrientationCorrection (string) --
The value of TargetImageOrientationCorrection is always null.
If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata that includes the image's orientation. Amazon Rekognition uses this orientation information to perform image correction. The bounding box coordinates are translated to represent object locations after the orientation information in the Exif metadata is used to correct the image orientation. Images in .png format don't contain Exif metadata.
Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without orientation information in the image Exif metadata. The bounding box coordinates aren't translated and represent the object locations before the image is rotated.
{'QualityFilter': ['MEDIUM', 'LOW', 'HIGH']}Response
{'UnindexedFaces': {'Reasons': ['LOW_FACE_QUALITY']}}
Detects faces in the input image and adds them to the specified collection.
Amazon Rekognition doesn't save the actual faces that are detected. Instead, the underlying detection algorithm first detects the faces in the input image. For each face, the algorithm extracts facial features into a feature vector, and stores it in the backend database. Amazon Rekognition uses feature vectors when it performs face match and search operations using the SearchFaces and SearchFacesByImage operations.
For more information, see Adding Faces to a Collection in the Amazon Rekognition Developer Guide.
To get the number of faces in a collection, call DescribeCollection .
If you're using version 1.0 of the face detection model, IndexFaces indexes the 15 largest faces in the input image. Later versions of the face detection model index the 100 largest faces in the input image.
If you're using version 4 or later of the face model, image orientation information is not returned in the OrientationCorrection field.
To determine which version of the model you're using, call DescribeCollection and supply the collection ID. You can also get the model version from the value of FaceModelVersion in the response from IndexFaces
For more information, see Model Versioning in the Amazon Rekognition Developer Guide.
If you provide the optional ExternalImageID for the input image you provided, Amazon Rekognition associates this ID with all faces that it detects. When you call the ListFaces operation, the response returns the external ID. You can use this external image ID to create a client-side index to associate the faces with each image. You can then use the index to find all faces in an image.
You can specify the maximum number of faces to index with the MaxFaces input parameter. This is useful when you want to index the largest faces in an image and don't want to index smaller faces, such as those belonging to people standing in the background.
The QualityFilter input parameter allows you to filter out detected faces that don’t meet a required quality bar. The quality bar is based on a variety of common use cases. By default, IndexFaces chooses the quality bar that's used to filter faces. You can also explicitly choose the quality bar. Use QualityFilter , to set the quality bar by specifying LOW , MEDIUM , or HIGH . If you do not want to filter detected faces, specify NONE .
Note
To use quality filtering, you need a collection associated with version 3 of the face model or higher. To get the version of the face model associated with a collection, call DescribeCollection .
Information about faces detected in an image, but not indexed, is returned in an array of UnindexedFace objects, UnindexedFaces . Faces aren't indexed for reasons such as:
The number of faces detected exceeds the value of the MaxFaces request parameter.
The face is too small compared to the image dimensions.
The face is too blurry.
The image is too dark.
The face has an extreme pose.
The face doesn’t have enough detail to be suitable for face search.
In response, the IndexFaces operation returns an array of metadata for all detected faces, FaceRecords . This includes:
The bounding box, BoundingBox , of the detected face.
A confidence value, Confidence , which indicates the confidence that the bounding box contains a face.
A face ID, FaceId , assigned by the service for each face that's detected and stored.
An image ID, ImageId , assigned by the service for the input image.
If you request all facial attributes (by using the detectionAttributes parameter), Amazon Rekognition returns detailed facial attributes, such as facial landmarks (for example, location of eye and mouth) and other facial attributes. If you provide the same image, specify the same collection, and use the same external ID in the IndexFaces operation, Amazon Rekognition doesn't save duplicate face metadata.
The input image is passed either as base64-encoded image bytes, or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes isn't supported. The image must be formatted as a PNG or JPEG file.
This operation requires permissions to perform the rekognition:IndexFaces action.
See also: AWS API Documentation
Request Syntax
client.index_faces( CollectionId='string', Image={ 'Bytes': b'bytes', 'S3Object': { 'Bucket': 'string', 'Name': 'string', 'Version': 'string' } }, ExternalImageId='string', DetectionAttributes=[ 'DEFAULT'|'ALL', ], MaxFaces=123, QualityFilter='NONE'|'AUTO'|'LOW'|'MEDIUM'|'HIGH' )
string
[REQUIRED]
The ID of an existing collection to which you want to add the faces that are detected in the input images.
dict
[REQUIRED]
The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing base64-encoded image bytes isn't supported.
If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the Bytes field. For more information, see Images in the Amazon Rekognition developer guide.
Bytes (bytes) --
Blob of image bytes up to 5 MBs.
S3Object (dict) --
Identifies an S3 object as the image source.
Bucket (string) --
Name of the S3 bucket.
Name (string) --
S3 object key name.
Version (string) --
If the bucket is versioning enabled, you can specify the object version.
string
The ID you want to assign to all the faces detected in the image.
list
An array of facial attributes that you want to be returned. This can be the default list of attributes or all attributes. If you don't specify a value for Attributes or if you specify ["DEFAULT"] , the API returns the following subset of facial attributes: BoundingBox , Confidence , Pose , Quality , and Landmarks . If you provide ["ALL"] , all facial attributes are returned, but the operation takes longer to complete.
If you provide both, ["ALL", "DEFAULT"] , the service uses a logical AND operator to determine which attributes to return (in this case, all attributes).
(string) --
integer
The maximum number of faces to index. The value of MaxFaces must be greater than or equal to 1. IndexFaces returns no more than 100 detected faces in an image, even if you specify a larger value for MaxFaces .
If IndexFaces detects more faces than the value of MaxFaces , the faces with the lowest quality are filtered out first. If there are still more faces than the value of MaxFaces , the faces with the smallest bounding boxes are filtered out (up to the number that's needed to satisfy the value of MaxFaces ). Information about the unindexed faces is available in the UnindexedFaces array.
The faces that are returned by IndexFaces are sorted by the largest face bounding box size to the smallest size, in descending order.
MaxFaces can be used with a collection associated with any version of the face model.
string
A filter that specifies a quality bar for how much filtering is done to identify faces. Filtered faces aren't indexed. If you specify AUTO , Amazon Rekognition chooses the quality bar. If you specify LOW , MEDIUM , or HIGH , filtering removes all faces that don’t meet the chosen quality bar. The default value is AUTO . The quality bar is based on a variety of common use cases. Low-quality detections can occur for a number of reasons. Some examples are an object that's misidentified as a face, a face that's too blurry, or a face with a pose that's too extreme to use. If you specify NONE , no filtering is performed.
To use quality filtering, the collection you are using must be associated with version 3 of the face model or higher.
dict
Response Syntax
{ 'FaceRecords': [ { 'Face': { 'FaceId': 'string', 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'ImageId': 'string', 'ExternalImageId': 'string', 'Confidence': ... }, 'FaceDetail': { 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'AgeRange': { 'Low': 123, 'High': 123 }, 'Smile': { 'Value': True|False, 'Confidence': ... }, 'Eyeglasses': { 'Value': True|False, 'Confidence': ... }, 'Sunglasses': { 'Value': True|False, 'Confidence': ... }, 'Gender': { 'Value': 'Male'|'Female', 'Confidence': ... }, 'Beard': { 'Value': True|False, 'Confidence': ... }, 'Mustache': { 'Value': True|False, 'Confidence': ... }, 'EyesOpen': { 'Value': True|False, 'Confidence': ... }, 'MouthOpen': { 'Value': True|False, 'Confidence': ... }, 'Emotions': [ { 'Type': 'HAPPY'|'SAD'|'ANGRY'|'CONFUSED'|'DISGUSTED'|'SURPRISED'|'CALM'|'UNKNOWN'|'FEAR', 'Confidence': ... }, ], 'Landmarks': [ { 'Type': 'eyeLeft'|'eyeRight'|'nose'|'mouthLeft'|'mouthRight'|'leftEyeBrowLeft'|'leftEyeBrowRight'|'leftEyeBrowUp'|'rightEyeBrowLeft'|'rightEyeBrowRight'|'rightEyeBrowUp'|'leftEyeLeft'|'leftEyeRight'|'leftEyeUp'|'leftEyeDown'|'rightEyeLeft'|'rightEyeRight'|'rightEyeUp'|'rightEyeDown'|'noseLeft'|'noseRight'|'mouthUp'|'mouthDown'|'leftPupil'|'rightPupil'|'upperJawlineLeft'|'midJawlineLeft'|'chinBottom'|'midJawlineRight'|'upperJawlineRight', 'X': ..., 'Y': ... }, ], 'Pose': { 'Roll': ..., 'Yaw': ..., 'Pitch': ... }, 'Quality': { 'Brightness': ..., 'Sharpness': ... }, 'Confidence': ... } }, ], 'OrientationCorrection': 'ROTATE_0'|'ROTATE_90'|'ROTATE_180'|'ROTATE_270', 'FaceModelVersion': 'string', 'UnindexedFaces': [ { 'Reasons': [ 'EXCEEDS_MAX_FACES'|'EXTREME_POSE'|'LOW_BRIGHTNESS'|'LOW_SHARPNESS'|'LOW_CONFIDENCE'|'SMALL_BOUNDING_BOX'|'LOW_FACE_QUALITY', ], 'FaceDetail': { 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'AgeRange': { 'Low': 123, 'High': 123 }, 'Smile': { 'Value': True|False, 'Confidence': ... }, 'Eyeglasses': { 'Value': True|False, 'Confidence': ... }, 'Sunglasses': { 'Value': True|False, 'Confidence': ... }, 'Gender': { 'Value': 'Male'|'Female', 'Confidence': ... }, 'Beard': { 'Value': True|False, 'Confidence': ... }, 'Mustache': { 'Value': True|False, 'Confidence': ... }, 'EyesOpen': { 'Value': True|False, 'Confidence': ... }, 'MouthOpen': { 'Value': True|False, 'Confidence': ... }, 'Emotions': [ { 'Type': 'HAPPY'|'SAD'|'ANGRY'|'CONFUSED'|'DISGUSTED'|'SURPRISED'|'CALM'|'UNKNOWN'|'FEAR', 'Confidence': ... }, ], 'Landmarks': [ { 'Type': 'eyeLeft'|'eyeRight'|'nose'|'mouthLeft'|'mouthRight'|'leftEyeBrowLeft'|'leftEyeBrowRight'|'leftEyeBrowUp'|'rightEyeBrowLeft'|'rightEyeBrowRight'|'rightEyeBrowUp'|'leftEyeLeft'|'leftEyeRight'|'leftEyeUp'|'leftEyeDown'|'rightEyeLeft'|'rightEyeRight'|'rightEyeUp'|'rightEyeDown'|'noseLeft'|'noseRight'|'mouthUp'|'mouthDown'|'leftPupil'|'rightPupil'|'upperJawlineLeft'|'midJawlineLeft'|'chinBottom'|'midJawlineRight'|'upperJawlineRight', 'X': ..., 'Y': ... }, ], 'Pose': { 'Roll': ..., 'Yaw': ..., 'Pitch': ... }, 'Quality': { 'Brightness': ..., 'Sharpness': ... }, 'Confidence': ... } }, ] }
Response Structure
(dict) --
FaceRecords (list) --
An array of faces detected and added to the collection. For more information, see Searching Faces in a Collection in the Amazon Rekognition Developer Guide.
(dict) --
Object containing both the face metadata (stored in the backend database), and facial attributes that are detected but aren't stored in the database.
Face (dict) --
Describes the face properties such as the bounding box, face ID, image ID of the input image, and external image ID that you assigned.
FaceId (string) --
Unique identifier that Amazon Rekognition assigns to the face.
BoundingBox (dict) --
Bounding box of the face.
Width (float) --
Width of the bounding box as a ratio of the overall image width.
Height (float) --
Height of the bounding box as a ratio of the overall image height.
Left (float) --
Left coordinate of the bounding box as a ratio of overall image width.
Top (float) --
Top coordinate of the bounding box as a ratio of overall image height.
ImageId (string) --
Unique identifier that Amazon Rekognition assigns to the input image.
ExternalImageId (string) --
Identifier that you assign to all the faces in the input image.
Confidence (float) --
Confidence level that the bounding box contains a face (and not a different object such as a tree).
FaceDetail (dict) --
Structure containing attributes of the face that the algorithm detected.
BoundingBox (dict) --
Bounding box of the face. Default attribute.
Width (float) --
Width of the bounding box as a ratio of the overall image width.
Height (float) --
Height of the bounding box as a ratio of the overall image height.
Left (float) --
Left coordinate of the bounding box as a ratio of overall image width.
Top (float) --
Top coordinate of the bounding box as a ratio of overall image height.
AgeRange (dict) --
The estimated age range, in years, for the face. Low represents the lowest estimated age and High represents the highest estimated age.
Low (integer) --
The lowest estimated age.
High (integer) --
The highest estimated age.
Smile (dict) --
Indicates whether or not the face is smiling, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face is smiling or not.
Confidence (float) --
Level of confidence in the determination.
Eyeglasses (dict) --
Indicates whether or not the face is wearing eye glasses, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face is wearing eye glasses or not.
Confidence (float) --
Level of confidence in the determination.
Sunglasses (dict) --
Indicates whether or not the face is wearing sunglasses, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face is wearing sunglasses or not.
Confidence (float) --
Level of confidence in the determination.
Gender (dict) --
The predicted gender of a detected face.
Value (string) --
The predicted gender of the face.
Confidence (float) --
Level of confidence in the prediction.
Beard (dict) --
Indicates whether or not the face has a beard, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face has beard or not.
Confidence (float) --
Level of confidence in the determination.
Mustache (dict) --
Indicates whether or not the face has a mustache, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face has mustache or not.
Confidence (float) --
Level of confidence in the determination.
EyesOpen (dict) --
Indicates whether or not the eyes on the face are open, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the eyes on the face are open.
Confidence (float) --
Level of confidence in the determination.
MouthOpen (dict) --
Indicates whether or not the mouth on the face is open, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the mouth on the face is open or not.
Confidence (float) --
Level of confidence in the determination.
Emotions (list) --
The emotions that appear to be expressed on the face, and the confidence level in the determination. The API is only making a determination of the physical appearance of a person's face. It is not a determination of the person’s internal emotional state and should not be used in such a way. For example, a person pretending to have a sad face might not be sad emotionally.
(dict) --
The emotions that appear to be expressed on the face, and the confidence level in the determination. The API is only making a determination of the physical appearance of a person's face. It is not a determination of the person’s internal emotional state and should not be used in such a way. For example, a person pretending to have a sad face might not be sad emotionally.
Type (string) --
Type of emotion detected.
Confidence (float) --
Level of confidence in the determination.
Landmarks (list) --
Indicates the location of landmarks on the face. Default attribute.
(dict) --
Indicates the location of the landmark on the face.
Type (string) --
Type of landmark.
X (float) --
The x-coordinate from the top left of the landmark expressed as the ratio of the width of the image. For example, if the image is 700 x 200 and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.
Y (float) --
The y-coordinate from the top left of the landmark expressed as the ratio of the height of the image. For example, if the image is 700 x 200 and the y-coordinate of the landmark is at 100 pixels, this value is 0.5.
Pose (dict) --
Indicates the pose of the face as determined by its pitch, roll, and yaw. Default attribute.
Roll (float) --
Value representing the face rotation on the roll axis.
Yaw (float) --
Value representing the face rotation on the yaw axis.
Pitch (float) --
Value representing the face rotation on the pitch axis.
Quality (dict) --
Identifies image brightness and sharpness. Default attribute.
Brightness (float) --
Value representing brightness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a brighter face image.
Sharpness (float) --
Value representing sharpness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a sharper face image.
Confidence (float) --
Confidence level that the bounding box contains a face (and not a different object such as a tree). Default attribute.
OrientationCorrection (string) --
If your collection is associated with a face detection model that's later than version 3.0, the value of OrientationCorrection is always null and no orientation information is returned.
If your collection is associated with a face detection model that's version 3.0 or earlier, the following applies:
If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata that includes the image's orientation. Amazon Rekognition uses this orientation information to perform image correction - the bounding box coordinates are translated to represent object locations after the orientation information in the Exif metadata is used to correct the image orientation. Images in .png format don't contain Exif metadata. The value of OrientationCorrection is null.
If the image doesn't contain orientation information in its Exif metadata, Amazon Rekognition returns an estimated orientation (ROTATE_0, ROTATE_90, ROTATE_180, ROTATE_270). Amazon Rekognition doesn’t perform image correction for images. The bounding box coordinates aren't translated and represent the object locations before the image is rotated.
Bounding box information is returned in the FaceRecords array. You can get the version of the face detection model by calling DescribeCollection .
FaceModelVersion (string) --
The version number of the face detection model that's associated with the input collection (CollectionId ).
UnindexedFaces (list) --
An array of faces that were detected in the image but weren't indexed. They weren't indexed because the quality filter identified them as low quality, or the MaxFaces request parameter filtered them out. To use the quality filter, you specify the QualityFilter request parameter.
(dict) --
A face that IndexFaces detected, but didn't index. Use the Reasons response attribute to determine why a face wasn't indexed.
Reasons (list) --
An array of reasons that specify why a face wasn't indexed.
EXTREME_POSE - The face is at a pose that can't be detected. For example, the head is turned too far away from the camera.
EXCEEDS_MAX_FACES - The number of faces detected is already higher than that specified by the MaxFaces input parameter for IndexFaces .
LOW_BRIGHTNESS - The image is too dark.
LOW_SHARPNESS - The image is too blurry.
LOW_CONFIDENCE - The face was detected with a low confidence.
SMALL_BOUNDING_BOX - The bounding box around the face is too small.
(string) --
FaceDetail (dict) --
The structure that contains attributes of a face that IndexFaces detected, but didn't index.
BoundingBox (dict) --
Bounding box of the face. Default attribute.
Width (float) --
Width of the bounding box as a ratio of the overall image width.
Height (float) --
Height of the bounding box as a ratio of the overall image height.
Left (float) --
Left coordinate of the bounding box as a ratio of overall image width.
Top (float) --
Top coordinate of the bounding box as a ratio of overall image height.
AgeRange (dict) --
The estimated age range, in years, for the face. Low represents the lowest estimated age and High represents the highest estimated age.
Low (integer) --
The lowest estimated age.
High (integer) --
The highest estimated age.
Smile (dict) --
Indicates whether or not the face is smiling, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face is smiling or not.
Confidence (float) --
Level of confidence in the determination.
Eyeglasses (dict) --
Indicates whether or not the face is wearing eye glasses, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face is wearing eye glasses or not.
Confidence (float) --
Level of confidence in the determination.
Sunglasses (dict) --
Indicates whether or not the face is wearing sunglasses, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face is wearing sunglasses or not.
Confidence (float) --
Level of confidence in the determination.
Gender (dict) --
The predicted gender of a detected face.
Value (string) --
The predicted gender of the face.
Confidence (float) --
Level of confidence in the prediction.
Beard (dict) --
Indicates whether or not the face has a beard, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face has beard or not.
Confidence (float) --
Level of confidence in the determination.
Mustache (dict) --
Indicates whether or not the face has a mustache, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the face has mustache or not.
Confidence (float) --
Level of confidence in the determination.
EyesOpen (dict) --
Indicates whether or not the eyes on the face are open, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the eyes on the face are open.
Confidence (float) --
Level of confidence in the determination.
MouthOpen (dict) --
Indicates whether or not the mouth on the face is open, and the confidence level in the determination.
Value (boolean) --
Boolean value that indicates whether the mouth on the face is open or not.
Confidence (float) --
Level of confidence in the determination.
Emotions (list) --
The emotions that appear to be expressed on the face, and the confidence level in the determination. The API is only making a determination of the physical appearance of a person's face. It is not a determination of the person’s internal emotional state and should not be used in such a way. For example, a person pretending to have a sad face might not be sad emotionally.
(dict) --
The emotions that appear to be expressed on the face, and the confidence level in the determination. The API is only making a determination of the physical appearance of a person's face. It is not a determination of the person’s internal emotional state and should not be used in such a way. For example, a person pretending to have a sad face might not be sad emotionally.
Type (string) --
Type of emotion detected.
Confidence (float) --
Level of confidence in the determination.
Landmarks (list) --
Indicates the location of landmarks on the face. Default attribute.
(dict) --
Indicates the location of the landmark on the face.
Type (string) --
Type of landmark.
X (float) --
The x-coordinate from the top left of the landmark expressed as the ratio of the width of the image. For example, if the image is 700 x 200 and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.
Y (float) --
The y-coordinate from the top left of the landmark expressed as the ratio of the height of the image. For example, if the image is 700 x 200 and the y-coordinate of the landmark is at 100 pixels, this value is 0.5.
Pose (dict) --
Indicates the pose of the face as determined by its pitch, roll, and yaw. Default attribute.
Roll (float) --
Value representing the face rotation on the roll axis.
Yaw (float) --
Value representing the face rotation on the yaw axis.
Pitch (float) --
Value representing the face rotation on the pitch axis.
Quality (dict) --
Identifies image brightness and sharpness. Default attribute.
Brightness (float) --
Value representing brightness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a brighter face image.
Sharpness (float) --
Value representing sharpness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a sharper face image.
Confidence (float) --
Confidence level that the bounding box contains a face (and not a different object such as a tree). Default attribute.
{'QualityFilter': 'NONE | AUTO | LOW | MEDIUM | HIGH'}
For a given input image, first detects the largest face in the image, and then searches the specified collection for matching faces. The operation compares the features of the input face with faces in the specified collection.
Note
To search for all faces in an input image, you might first call the IndexFaces operation, and then use the face IDs returned in subsequent calls to the SearchFaces operation.
You can also call the DetectFaces operation and use the bounding boxes in the response to make face crops, which then you can pass in to the SearchFacesByImage operation.
You pass the input image either as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.
The response returns an array of faces that match, ordered by similarity score with the highest similarity first. More specifically, it is an array of metadata for each face match found. Along with the metadata, the response also includes a similarity indicating how similar the face is to the input face. In the response, the operation also returns the bounding box (and a confidence level that the bounding box contains a face) of the face that Amazon Rekognition used for the input image.
For an example, Searching for a Face Using an Image in the Amazon Rekognition Developer Guide.
The QualityFilter input parameter allows you to filter out detected faces that don’t meet a required quality bar. The quality bar is based on a variety of common use cases. By default, Amazon Rekognition chooses the quality bar that's used to filter faces. You can also explicitly choose the quality bar. Use QualityFilter , to set the quality bar for filtering by specifying LOW , MEDIUM , or HIGH . If you do not want to filter detected faces, specify NONE .
Note
To use quality filtering, you need a collection associated with version 3 of the face model or higher. To get the version of the face model associated with a collection, call DescribeCollection .
This operation requires permissions to perform the rekognition:SearchFacesByImage action.
See also: AWS API Documentation
Request Syntax
client.search_faces_by_image( CollectionId='string', Image={ 'Bytes': b'bytes', 'S3Object': { 'Bucket': 'string', 'Name': 'string', 'Version': 'string' } }, MaxFaces=123, FaceMatchThreshold=..., QualityFilter='NONE'|'AUTO'|'LOW'|'MEDIUM'|'HIGH' )
string
[REQUIRED]
ID of the collection to search.
dict
[REQUIRED]
The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing base64-encoded image bytes is not supported.
If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the Bytes field. For more information, see Images in the Amazon Rekognition developer guide.
Bytes (bytes) --
Blob of image bytes up to 5 MBs.
S3Object (dict) --
Identifies an S3 object as the image source.
Bucket (string) --
Name of the S3 bucket.
Name (string) --
S3 object key name.
Version (string) --
If the bucket is versioning enabled, you can specify the object version.
integer
Maximum number of faces to return. The operation returns the maximum number of faces with the highest confidence in the match.
float
(Optional) Specifies the minimum confidence in the face match to return. For example, don't return any matches where confidence in matches is less than 70%. The default value is 80%.
string
A filter that specifies a quality bar for how much filtering is done to identify faces. Filtered faces aren't searched for in the collection. If you specify AUTO , Amazon Rekognition chooses the quality bar. If you specify LOW , MEDIUM , or HIGH , filtering removes all faces that don’t meet the chosen quality bar. The default value is AUTO . The quality bar is based on a variety of common use cases. Low-quality detections can occur for a number of reasons. Some examples are an object that's misidentified as a face, a face that's too blurry, or a face with a pose that's too extreme to use. If you specify NONE , no filtering is performed.
To use quality filtering, the collection you are using must be associated with version 3 of the face model or higher.
dict
Response Syntax
{ 'SearchedFaceBoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'SearchedFaceConfidence': ..., 'FaceMatches': [ { 'Similarity': ..., 'Face': { 'FaceId': 'string', 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'ImageId': 'string', 'ExternalImageId': 'string', 'Confidence': ... } }, ], 'FaceModelVersion': 'string' }
Response Structure
(dict) --
SearchedFaceBoundingBox (dict) --
The bounding box around the face in the input image that Amazon Rekognition used for the search.
Width (float) --
Width of the bounding box as a ratio of the overall image width.
Height (float) --
Height of the bounding box as a ratio of the overall image height.
Left (float) --
Left coordinate of the bounding box as a ratio of overall image width.
Top (float) --
Top coordinate of the bounding box as a ratio of overall image height.
SearchedFaceConfidence (float) --
The level of confidence that the searchedFaceBoundingBox , contains a face.
FaceMatches (list) --
An array of faces that match the input face, along with the confidence in the match.
(dict) --
Provides face metadata. In addition, it also provides the confidence in the match of this face with the input face.
Similarity (float) --
Confidence in the match of this face with the input face.
Face (dict) --
Describes the face properties such as the bounding box, face ID, image ID of the source image, and external image ID that you assigned.
FaceId (string) --
Unique identifier that Amazon Rekognition assigns to the face.
BoundingBox (dict) --
Bounding box of the face.
Width (float) --
Width of the bounding box as a ratio of the overall image width.
Height (float) --
Height of the bounding box as a ratio of the overall image height.
Left (float) --
Left coordinate of the bounding box as a ratio of overall image width.
Top (float) --
Top coordinate of the bounding box as a ratio of overall image height.
ImageId (string) --
Unique identifier that Amazon Rekognition assigns to the input image.
ExternalImageId (string) --
Identifier that you assign to all the faces in the input image.
Confidence (float) --
Confidence level that the bounding box contains a face (and not a different object such as a tree).
FaceModelVersion (string) --
Version number of the face detection model associated with the input collection (CollectionId ).