2022/01/04 - Amazon Rekognition - 5 updated api methods
Changes This release introduces a new field IndexFacesModelVersion, which is the version of the face detect and storage model that was used when indexing the face vector.
{'Persons': {'FaceMatches': {'Face': {'IndexFacesModelVersion': 'string'}}}}
Gets the face search results for Amazon Rekognition Video face search started by StartFaceSearch . The search returns faces in a collection that match the faces of persons detected in a video. It also includes the time(s) that faces are matched in the video.
Face search in a video is an asynchronous operation. You start face search by calling to StartFaceSearch which returns a job identifier (JobId ). When the search operation finishes, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic registered in the initial call to StartFaceSearch . To get the search results, first check that the status value published to the Amazon SNS topic is SUCCEEDED . If so, call GetFaceSearch and pass the job identifier (JobId ) from the initial call to StartFaceSearch .
For more information, see Searching Faces in a Collection in the Amazon Rekognition Developer Guide.
The search results are retured in an array, Persons , of PersonMatch objects. Each``PersonMatch`` element contains details about the matching faces in the input collection, person information (facial attributes, bounding boxes, and person identifer) for the matched person, and the time the person was matched in the video.
Note
GetFaceSearch only returns the default facial attributes (BoundingBox , Confidence , Landmarks , Pose , and Quality ). The other facial attributes listed in the Face object of the following response syntax are not returned. For more information, see FaceDetail in the Amazon Rekognition Developer Guide.
By default, the Persons array is sorted by the time, in milliseconds from the start of the video, persons are matched. You can also sort by persons by specifying INDEX for the SORTBY input parameter.
See also: AWS API Documentation
Request Syntax
client.get_face_search( JobId='string', MaxResults=123, NextToken='string', SortBy='INDEX'|'TIMESTAMP' )
string
[REQUIRED]
The job identifer for the search request. You get the job identifier from an initial call to StartFaceSearch .
integer
Maximum number of results to return per paginated call. The largest value you can specify is 1000. If you specify a value greater than 1000, a maximum of 1000 results is returned. The default value is 1000.
string
If the previous response was incomplete (because there is more search results to retrieve), Amazon Rekognition Video returns a pagination token in the response. You can use this pagination token to retrieve the next set of search results.
string
Sort to use for grouping faces in the response. Use TIMESTAMP to group faces by the time that they are recognized. Use INDEX to sort by recognized faces.
dict
Response Syntax
{ 'JobStatus': 'IN_PROGRESS'|'SUCCEEDED'|'FAILED', 'StatusMessage': 'string', 'NextToken': 'string', 'VideoMetadata': { 'Codec': 'string', 'DurationMillis': 123, 'Format': 'string', 'FrameRate': ..., 'FrameHeight': 123, 'FrameWidth': 123, 'ColorRange': 'FULL'|'LIMITED' }, 'Persons': [ { 'Timestamp': 123, 'Person': { 'Index': 123, 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'Face': { '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': ... } }, 'FaceMatches': [ { 'Similarity': ..., 'Face': { 'FaceId': 'string', 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'ImageId': 'string', 'ExternalImageId': 'string', 'Confidence': ..., 'IndexFacesModelVersion': 'string' } }, ] }, ] }
Response Structure
(dict) --
JobStatus (string) --
The current status of the face search job.
StatusMessage (string) --
If the job fails, StatusMessage provides a descriptive error message.
NextToken (string) --
If the response is truncated, Amazon Rekognition Video returns this token that you can use in the subsequent request to retrieve the next set of search results.
VideoMetadata (dict) --
Information about a video that Amazon Rekognition analyzed. Videometadata is returned in every page of paginated responses from a Amazon Rekognition Video operation.
Codec (string) --
Type of compression used in the analyzed video.
DurationMillis (integer) --
Length of the video in milliseconds.
Format (string) --
Format of the analyzed video. Possible values are MP4, MOV and AVI.
FrameRate (float) --
Number of frames per second in the video.
FrameHeight (integer) --
Vertical pixel dimension of the video.
FrameWidth (integer) --
Horizontal pixel dimension of the video.
ColorRange (string) --
A description of the range of luminance values in a video, either LIMITED (16 to 235) or FULL (0 to 255).
Persons (list) --
An array of persons, PersonMatch , in the video whose face(s) match the face(s) in an Amazon Rekognition collection. It also includes time information for when persons are matched in the video. You specify the input collection in an initial call to StartFaceSearch . Each Persons element includes a time the person was matched, face match details (FaceMatches ) for matching faces in the collection, and person information (Person ) for the matched person.
(dict) --
Information about a person whose face matches a face(s) in an Amazon Rekognition collection. Includes information about the faces in the Amazon Rekognition collection ( FaceMatch ), information about the person ( PersonDetail ), and the time stamp for when the person was detected in a video. An array of PersonMatch objects is returned by GetFaceSearch .
Timestamp (integer) --
The time, in milliseconds from the beginning of the video, that the person was matched in the video.
Person (dict) --
Information about the matched person.
Index (integer) --
Identifier for the person detected person within a video. Use to keep track of the person throughout the video. The identifier is not stored by Amazon Rekognition.
BoundingBox (dict) --
Bounding box around the detected person.
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.
Face (dict) --
Face details for the detected person.
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 of the landmark expressed as a ratio of the width of the image. The x-coordinate is measured from the left-side of the image. For example, if the image is 700 pixels wide and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.
Y (float) --
The y-coordinate of the landmark expressed as a ratio of the height of the image. The y-coordinate is measured from the top of the image. For example, if the image height is 200 pixels and the y-coordinate of the landmark is at 50 pixels, this value is 0.25.
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.
FaceMatches (list) --
Information about the faces in the input collection that match the face of a person in the video.
(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).
IndexFacesModelVersion (string) --
The version of the face detect and storage model that was used when indexing the face vector.
{'FaceRecords': {'Face': {'IndexFacesModelVersion': 'string'}}}
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, use the same external ID, and use the same model version 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': ..., 'IndexFacesModelVersion': 'string' }, '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).
IndexFacesModelVersion (string) --
The version of the face detect and storage model that was used when indexing the face vector.
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 of the landmark expressed as a ratio of the width of the image. The x-coordinate is measured from the left-side of the image. For example, if the image is 700 pixels wide and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.
Y (float) --
The y-coordinate of the landmark expressed as a ratio of the height of the image. The y-coordinate is measured from the top of the image. For example, if the image height is 200 pixels and the y-coordinate of the landmark is at 50 pixels, this value is 0.25.
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) --
Latest face model being used with the collection. For more information, see Model versioning .
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 of the landmark expressed as a ratio of the width of the image. The x-coordinate is measured from the left-side of the image. For example, if the image is 700 pixels wide and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.
Y (float) --
The y-coordinate of the landmark expressed as a ratio of the height of the image. The y-coordinate is measured from the top of the image. For example, if the image height is 200 pixels and the y-coordinate of the landmark is at 50 pixels, this value is 0.25.
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.
{'Faces': {'IndexFacesModelVersion': 'string'}}
Returns metadata for faces in the specified collection. This metadata includes information such as the bounding box coordinates, the confidence (that the bounding box contains a face), and face ID. For an example, see Listing Faces in a Collection in the Amazon Rekognition Developer Guide.
This operation requires permissions to perform the rekognition:ListFaces action.
See also: AWS API Documentation
Request Syntax
client.list_faces( CollectionId='string', NextToken='string', MaxResults=123 )
string
[REQUIRED]
ID of the collection from which to list the faces.
string
If the previous response was incomplete (because there is more data to retrieve), Amazon Rekognition returns a pagination token in the response. You can use this pagination token to retrieve the next set of faces.
integer
Maximum number of faces to return.
dict
Response Syntax
{ 'Faces': [ { 'FaceId': 'string', 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'ImageId': 'string', 'ExternalImageId': 'string', 'Confidence': ..., 'IndexFacesModelVersion': 'string' }, ], 'NextToken': 'string', 'FaceModelVersion': 'string' }
Response Structure
(dict) --
Faces (list) --
An array of Face objects.
(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).
IndexFacesModelVersion (string) --
The version of the face detect and storage model that was used when indexing the face vector.
NextToken (string) --
If the response is truncated, Amazon Rekognition returns this token that you can use in the subsequent request to retrieve the next set of faces.
FaceModelVersion (string) --
Latest face model being used with the collection. For more information, see Model versioning .
{'FaceMatches': {'Face': {'IndexFacesModelVersion': 'string'}}}
For a given input face ID, searches for matching faces in the collection the face belongs to. You get a face ID when you add a face to the collection using the IndexFaces operation. The operation compares the features of the input face with faces in the specified collection.
Note
You can also search faces without indexing faces by using the SearchFacesByImage operation.
The operation 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 that is found. Along with the metadata, the response also includes a confidence value for each face match, indicating the confidence that the specific face matches the input face.
For an example, see Searching for a Face Using Its Face ID in the Amazon Rekognition Developer Guide.
This operation requires permissions to perform the rekognition:SearchFaces action.
See also: AWS API Documentation
Request Syntax
client.search_faces( CollectionId='string', FaceId='string', MaxFaces=123, FaceMatchThreshold=... )
string
[REQUIRED]
ID of the collection the face belongs to.
string
[REQUIRED]
ID of a face to find matches for in the collection.
integer
Maximum number of faces to return. The operation returns the maximum number of faces with the highest confidence in the match.
float
Optional value specifying 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%.
dict
Response Syntax
{ 'SearchedFaceId': 'string', 'FaceMatches': [ { 'Similarity': ..., 'Face': { 'FaceId': 'string', 'BoundingBox': { 'Width': ..., 'Height': ..., 'Left': ..., 'Top': ... }, 'ImageId': 'string', 'ExternalImageId': 'string', 'Confidence': ..., 'IndexFacesModelVersion': 'string' } }, ], 'FaceModelVersion': 'string' }
Response Structure
(dict) --
SearchedFaceId (string) --
ID of the face that was searched for matches in a collection.
FaceMatches (list) --
An array of faces that matched 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).
IndexFacesModelVersion (string) --
The version of the face detect and storage model that was used when indexing the face vector.
FaceModelVersion (string) --
Latest face model being used with the collection. For more information, see Model versioning .
{'FaceMatches': {'Face': {'IndexFacesModelVersion': 'string'}}}
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.
If no faces are detected in the input image, SearchFacesByImage returns an InvalidParameterException error.
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. 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 . The default value is 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 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. The default value is NONE .
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': ..., 'IndexFacesModelVersion': 'string' } }, ], '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).
IndexFacesModelVersion (string) --
The version of the face detect and storage model that was used when indexing the face vector.
FaceModelVersion (string) --
Latest face model being used with the collection. For more information, see Model versioning .