Amazon Rekognition

2023/06/12 - Amazon Rekognition - 7 new 7 updated api methods

Changes  This release adds support for improved accuracy with user vector in Amazon Rekognition Face Search. Adds new APIs: AssociateFaces, CreateUser, DeleteUser, DisassociateFaces, ListUsers, SearchUsers, SearchUsersByImage. Also adds new face metadata that can be stored: user vector.

AssociateFaces (new) Link ¶

Associates one or more faces with an existing UserID. Takes an array of FaceIds . Each FaceId that are present in the FaceIds list is associated with the provided UserID. The maximum number of total FaceIds per UserID is 100.

The UserMatchThreshold parameter specifies the minimum user match confidence required for the face to be associated with a UserID that has at least one FaceID already associated. This ensures that the FaceIds are associated with the right UserID. The value ranges from 0-100 and default value is 75.

If successful, an array of AssociatedFace objects containing the associated FaceIds is returned. If a given face is already associated with the given UserID , it will be ignored and will not be returned in the response. If a given face is already associated to a different UserID , isn't found in the collection, doesn’t meet the UserMatchThreshold , or there are already 100 faces associated with the UserID , it will be returned as part of an array of UnsuccessfulFaceAssociations.

The UserStatus reflects the status of an operation which updates a UserID representation with a list of given faces. The UserStatus can be:

  • ACTIVE - All associations or disassociations of FaceID(s) for a UserID are complete.

  • CREATED - A UserID has been created, but has no FaceID(s) associated with it.

  • UPDATING - A UserID is being updated and there are current associations or disassociations of FaceID(s) taking place.

See also: AWS API Documentation

Request Syntax

client.associate_faces(
    CollectionId='string',
    UserId='string',
    FaceIds=[
        'string',
    ],
    UserMatchThreshold=...,
    ClientRequestToken='string'
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of an existing collection containing the UserID.

type UserId

string

param UserId

[REQUIRED]

The ID for the existing UserID.

type FaceIds

list

param FaceIds

[REQUIRED]

An array of FaceIDs to associate with the UserID.

  • (string) --

type UserMatchThreshold

float

param UserMatchThreshold

An optional value specifying the minimum confidence in the UserID match to return. The default value is 75.

type ClientRequestToken

string

param ClientRequestToken

Idempotent token used to identify the request to AssociateFaces . If you use the same token with multiple AssociateFaces requests, the same response is returned. Use ClientRequestToken to prevent the same request from being processed more than once.

This field is autopopulated if not provided.

rtype

dict

returns

Response Syntax

{
    'AssociatedFaces': [
        {
            'FaceId': 'string'
        },
    ],
    'UnsuccessfulFaceAssociations': [
        {
            'FaceId': 'string',
            'UserId': 'string',
            'Confidence': ...,
            'Reasons': [
                'FACE_NOT_FOUND'|'ASSOCIATED_TO_A_DIFFERENT_USER'|'LOW_MATCH_CONFIDENCE',
            ]
        },
    ],
    'UserStatus': 'ACTIVE'|'UPDATING'|'CREATING'|'CREATED'
}

Response Structure

  • (dict) --

    • AssociatedFaces (list) --

      An array of AssociatedFace objects containing FaceIDs that are successfully associated with the UserID is returned. Returned if the AssociateFaces action is successful.

      • (dict) --

        Provides face metadata for the faces that are associated to a specific UserID.

        • FaceId (string) --

          Unique identifier assigned to the face.

    • UnsuccessfulFaceAssociations (list) --

      An array of UnsuccessfulAssociation objects containing FaceIDs that are not successfully associated along with the reasons. Returned if the AssociateFaces action is successful.

      • (dict) --

        Contains metadata like FaceId, UserID, and Reasons, for a face that was unsuccessfully associated.

        • FaceId (string) --

          A unique identifier assigned to the face.

        • UserId (string) --

          A provided ID for the UserID. Unique within the collection.

        • Confidence (float) --

          Match confidence with the UserID, provides information regarding if a face association was unsuccessful because it didn't meet UserMatchThreshold.

        • Reasons (list) --

          The reason why the association was unsuccessful.

          • (string) --

    • UserStatus (string) --

      The status of an update made to a UserID. Reflects if the UserID has been updated for every requested change.

SearchUsers (new) Link ¶

Searches for UserIDs within a collection based on a FaceId or UserId . This API can be used to find the closest UserID (with a highest similarity) to associate a face. The request must be provided with either FaceId or UserId . The operation returns an array of UserID that match the FaceId or UserId , ordered by similarity score with the highest similarity first.

See also: AWS API Documentation

Request Syntax

client.search_users(
    CollectionId='string',
    UserId='string',
    FaceId='string',
    UserMatchThreshold=...,
    MaxUsers=123
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of an existing collection containing the UserID, used with a UserId or FaceId. If a FaceId is provided, UserId isn’t required to be present in the Collection.

type UserId

string

param UserId

ID for the existing User.

type FaceId

string

param FaceId

ID for the existing face.

type UserMatchThreshold

float

param UserMatchThreshold

Optional value that specifies the minimum confidence in the matched UserID to return. Default value of 80.

type MaxUsers

integer

param MaxUsers

Maximum number of identities to return.

rtype

dict

returns

Response Syntax

{
    'UserMatches': [
        {
            'Similarity': ...,
            'User': {
                'UserId': 'string',
                'UserStatus': 'ACTIVE'|'UPDATING'|'CREATING'|'CREATED'
            }
        },
    ],
    'FaceModelVersion': 'string',
    'SearchedFace': {
        'FaceId': 'string'
    },
    'SearchedUser': {
        'UserId': 'string'
    }
}

Response Structure

  • (dict) --

    • UserMatches (list) --

      An array of UserMatch objects that matched the input face along with the confidence in the match. Array will be empty if there are no matches.

      • (dict) --

        Provides UserID metadata along with the confidence in the match of this UserID with the input face.

        • Similarity (float) --

          Describes the UserID metadata.

        • User (dict) --

          Confidence in the match of this UserID with the input face.

          • UserId (string) --

            A provided ID for the UserID. Unique within the collection.

          • UserStatus (string) --

            The status of the user matched to a provided FaceID.

    • FaceModelVersion (string) --

      Version number of the face detection model associated with the input CollectionId.

    • SearchedFace (dict) --

      Contains the ID of a face that was used to search for matches in a collection.

      • FaceId (string) --

        Unique identifier assigned to the face.

    • SearchedUser (dict) --

      Contains the ID of the UserID that was used to search for matches in a collection.

      • UserId (string) --

        A provided ID for the UserID. Unique within the collection.

SearchUsersByImage (new) Link ¶

Searches for UserIDs using a supplied image. It first detects the largest face in the image, and then searches a specified collection for matching UserIDs.

The operation returns an array of UserIDs that match the face in the supplied image, ordered by similarity score with the highest similarity first. It also returns a bounding box for the face found in the input image.

Information about faces detected in the supplied image, but not used for the search, is returned in an array of UnsearchedFace objects. If no valid face is detected in the image, the response will contain an empty UserMatches list and no SearchedFace object.

See also: AWS API Documentation

Request Syntax

client.search_users_by_image(
    CollectionId='string',
    Image={
        'Bytes': b'bytes',
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
    UserMatchThreshold=...,
    MaxUsers=123,
    QualityFilter='NONE'|'AUTO'|'LOW'|'MEDIUM'|'HIGH'
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of an existing collection containing the UserID.

type Image

dict

param Image

[REQUIRED]

Provides the input image either as bytes or an S3 object.

You pass image bytes to an Amazon Rekognition API operation by using the Bytes property. For example, you would use the Bytes property to pass an image loaded from a local file system. Image bytes passed by using the Bytes property must be base64-encoded. Your code may not need to encode image bytes if you are using an AWS SDK to call Amazon Rekognition API operations.

For more information, see Analyzing an Image Loaded from a Local File System in the Amazon Rekognition Developer Guide.

You pass images stored in an S3 bucket to an Amazon Rekognition API operation by using the S3Object property. Images stored in an S3 bucket do not need to be base64-encoded.

The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.

If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes using the Bytes property is not supported. You must first upload the image to an Amazon S3 bucket and then call the operation using the S3Object property.

For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see How Amazon Rekognition works with IAM in the Amazon Rekognition Developer Guide.

  • Bytes (bytes) --

    Blob of image bytes up to 5 MBs. Note that the maximum image size you can pass to DetectCustomLabels is 4MB.

  • 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.

type UserMatchThreshold

float

param UserMatchThreshold

Specifies the minimum confidence in the UserID match to return. Default value is 80.

type MaxUsers

integer

param MaxUsers

Maximum number of UserIDs to return.

type QualityFilter

string

param QualityFilter

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. The default value is NONE.

rtype

dict

returns

Response Syntax

{
    'UserMatches': [
        {
            'Similarity': ...,
            'User': {
                'UserId': 'string',
                'UserStatus': 'ACTIVE'|'UPDATING'|'CREATING'|'CREATED'
            }
        },
    ],
    'FaceModelVersion': 'string',
    'SearchedFace': {
        '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': ...,
            'FaceOccluded': {
                'Value': True|False,
                'Confidence': ...
            },
            'EyeDirection': {
                'Yaw': ...,
                'Pitch': ...,
                'Confidence': ...
            }
        }
    },
    'UnsearchedFaces': [
        {
            'FaceDetails': {
                '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': ...,
                'FaceOccluded': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'EyeDirection': {
                    'Yaw': ...,
                    'Pitch': ...,
                    'Confidence': ...
                }
            },
            'Reasons': [
                'FACE_NOT_LARGEST'|'EXCEEDS_MAX_FACES'|'EXTREME_POSE'|'LOW_BRIGHTNESS'|'LOW_SHARPNESS'|'LOW_CONFIDENCE'|'SMALL_BOUNDING_BOX'|'LOW_FACE_QUALITY',
            ]
        },
    ]
}

Response Structure

  • (dict) --

    • UserMatches (list) --

      An array of UserID objects that matched the input face, along with the confidence in the match. The returned structure will be empty if there are no matches. Returned if the SearchUsersByImageResponse action is successful.

      • (dict) --

        Provides UserID metadata along with the confidence in the match of this UserID with the input face.

        • Similarity (float) --

          Describes the UserID metadata.

        • User (dict) --

          Confidence in the match of this UserID with the input face.

          • UserId (string) --

            A provided ID for the UserID. Unique within the collection.

          • UserStatus (string) --

            The status of the user matched to a provided FaceID.

    • FaceModelVersion (string) --

      Version number of the face detection model associated with the input collection CollectionId.

    • SearchedFace (dict) --

      A list of FaceDetail objects containing the BoundingBox for the largest face in image, as well as the confidence in the bounding box, that was searched for matches. If no valid face is detected in the image the response will contain no SearchedFace object.

      • FaceDetail (dict) --

        Structure containing attributes of the face that the algorithm detected.

        A FaceDetail object contains either the default facial attributes or all facial attributes. The default attributes are BoundingBox , Confidence , Landmarks , Pose , and Quality .

        GetFaceDetection is the only Amazon Rekognition Video stored video operation that can return a FaceDetail object with all attributes. To specify which attributes to return, use the FaceAttributes input parameter for StartFaceDetection . The following Amazon Rekognition Video operations return only the default attributes. The corresponding Start operations don't have a FaceAttributes input parameter:

        • GetCelebrityRecognition

        • GetPersonTracking

        • GetFaceSearch

        The Amazon Rekognition Image DetectFaces and IndexFaces operations can return all facial attributes. To specify which attributes to return, use the Attributes input parameter for DetectFaces . For IndexFaces , use the DetectAttributes input parameter.

        • 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.

        • FaceOccluded (dict) --

          FaceOccluded should return "true" with a high confidence score if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. FaceOccluded should return "false" with a high confidence score if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

          • Value (boolean) --

            True if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. False if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

          • Confidence (float) --

            The confidence that the service has detected the presence of a face occlusion.

        • EyeDirection (dict) --

          Indicates the direction the eyes are gazing in, as defined by pitch and yaw.

          • Yaw (float) --

            Value representing eye direction on the yaw axis.

          • Pitch (float) --

            Value representing eye direction on the pitch axis.

          • Confidence (float) --

            The confidence that the service has in its predicted eye direction.

    • UnsearchedFaces (list) --

      List of UnsearchedFace objects. Contains the face details infered from the specified image but not used for search. Contains reasons that describe why a face wasn't used for Search.

      • (dict) --

        Face details inferred from the image but not used for search. The response attribute contains reasons for why a face wasn't used for Search.

        • FaceDetails (dict) --

          Structure containing attributes of the face that the algorithm detected.

          A FaceDetail object contains either the default facial attributes or all facial attributes. The default attributes are BoundingBox , Confidence , Landmarks , Pose , and Quality .

          GetFaceDetection is the only Amazon Rekognition Video stored video operation that can return a FaceDetail object with all attributes. To specify which attributes to return, use the FaceAttributes input parameter for StartFaceDetection . The following Amazon Rekognition Video operations return only the default attributes. The corresponding Start operations don't have a FaceAttributes input parameter:

          • GetCelebrityRecognition

          • GetPersonTracking

          • GetFaceSearch

          The Amazon Rekognition Image DetectFaces and IndexFaces operations can return all facial attributes. To specify which attributes to return, use the Attributes input parameter for DetectFaces . For IndexFaces , use the DetectAttributes input parameter.

          • 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.

          • FaceOccluded (dict) --

            FaceOccluded should return "true" with a high confidence score if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. FaceOccluded should return "false" with a high confidence score if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

            • Value (boolean) --

              True if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. False if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

            • Confidence (float) --

              The confidence that the service has detected the presence of a face occlusion.

          • EyeDirection (dict) --

            Indicates the direction the eyes are gazing in, as defined by pitch and yaw.

            • Yaw (float) --

              Value representing eye direction on the yaw axis.

            • Pitch (float) --

              Value representing eye direction on the pitch axis.

            • Confidence (float) --

              The confidence that the service has in its predicted eye direction.

        • Reasons (list) --

          Reasons why a face wasn't used for Search.

          • (string) --

CreateUser (new) Link ¶

Creates a new User within a collection specified by CollectionId . Takes UserId as a parameter, which is a user provided ID which should be unique within the collection. The provided UserId will alias the system generated UUID to make the UserId more user friendly.

Uses a ClientToken , an idempotency token that ensures a call to CreateUser completes only once. If the value is not supplied, the AWS SDK generates an idempotency token for the requests. This prevents retries after a network error results from making multiple CreateUser calls.

See also: AWS API Documentation

Request Syntax

client.create_user(
    CollectionId='string',
    UserId='string',
    ClientRequestToken='string'
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of an existing collection to which the new UserID needs to be created.

type UserId

string

param UserId

[REQUIRED]

ID for the UserID to be created. This ID needs to be unique within the collection.

type ClientRequestToken

string

param ClientRequestToken

Idempotent token used to identify the request to CreateUser . If you use the same token with multiple CreateUser requests, the same response is returned. Use ClientRequestToken to prevent the same request from being processed more than once.

This field is autopopulated if not provided.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

DeleteUser (new) Link ¶

Deletes the specified UserID within the collection. Faces that are associated with the UserID are disassociated from the UserID before deleting the specified UserID. If the specified Collection or UserID is already deleted or not found, a ResourceNotFoundException will be thrown. If the action is successful with a 200 response, an empty HTTP body is returned.

See also: AWS API Documentation

Request Syntax

client.delete_user(
    CollectionId='string',
    UserId='string',
    ClientRequestToken='string'
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of an existing collection from which the UserID needs to be deleted.

type UserId

string

param UserId

[REQUIRED]

ID for the UserID to be deleted.

type ClientRequestToken

string

param ClientRequestToken

Idempotent token used to identify the request to DeleteUser . If you use the same token with multiple DeleteUser requests, the same response is returned. Use ClientRequestToken to prevent the same request from being processed more than once.

This field is autopopulated if not provided.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

DisassociateFaces (new) Link ¶

Removes the association between a Face supplied in an array of FaceIds and the User. If the User is not present already, then a ResourceNotFound exception is thrown. If successful, an array of faces that are disassociated from the User is returned. If a given face is already disassociated from the given UserID, it will be ignored and not be returned in the response. If a given face is already associated with a different User or not found in the collection it will be returned as part of UnsuccessfulDisassociations . You can remove 1 - 100 face IDs from a user at one time.

See also: AWS API Documentation

Request Syntax

client.disassociate_faces(
    CollectionId='string',
    UserId='string',
    ClientRequestToken='string',
    FaceIds=[
        'string',
    ]
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of an existing collection containing the UserID.

type UserId

string

param UserId

[REQUIRED]

ID for the existing UserID.

type ClientRequestToken

string

param ClientRequestToken

Idempotent token used to identify the request to DisassociateFaces . If you use the same token with multiple DisassociateFaces requests, the same response is returned. Use ClientRequestToken to prevent the same request from being processed more than once.

This field is autopopulated if not provided.

type FaceIds

list

param FaceIds

[REQUIRED]

An array of face IDs to disassociate from the UserID.

  • (string) --

rtype

dict

returns

Response Syntax

{
    'DisassociatedFaces': [
        {
            'FaceId': 'string'
        },
    ],
    'UnsuccessfulFaceDisassociations': [
        {
            'FaceId': 'string',
            'UserId': 'string',
            'Reasons': [
                'FACE_NOT_FOUND'|'ASSOCIATED_TO_A_DIFFERENT_USER',
            ]
        },
    ],
    'UserStatus': 'ACTIVE'|'UPDATING'|'CREATING'|'CREATED'
}

Response Structure

  • (dict) --

    • DisassociatedFaces (list) --

      An array of DissociatedFace objects containing FaceIds that are successfully disassociated with the UserID is returned. Returned if the DisassociatedFaces action is successful.

      • (dict) --

        Provides face metadata for the faces that are disassociated from a specific UserID.

        • FaceId (string) --

          Unique identifier assigned to the face.

    • UnsuccessfulFaceDisassociations (list) --

      An array of UnsuccessfulDisassociation objects containing FaceIds that are not successfully associated, along with the reasons for the failure to associate. Returned if the DisassociateFaces action is successful.

      • (dict) --

        Contains metadata like FaceId, UserID, and Reasons, for a face that was unsuccessfully disassociated.

        • FaceId (string) --

          A unique identifier assigned to the face.

        • UserId (string) --

          A provided ID for the UserID. Unique within the collection.

        • Reasons (list) --

          The reason why the deletion was unsuccessful.

          • (string) --

    • UserStatus (string) --

      The status of an update made to a User. Reflects if the User has been updated for every requested change.

ListUsers (new) Link ¶

Returns metadata of the User such as UserID in the specified collection. Anonymous User (to reserve faces without any identity) is not returned as part of this request. The results are sorted by system generated primary key ID. If the response is truncated, NextToken is returned in the response that can be used in the subsequent request to retrieve the next set of identities.

See also: AWS API Documentation

Request Syntax

client.list_users(
    CollectionId='string',
    MaxResults=123,
    NextToken='string'
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of an existing collection.

type MaxResults

integer

param MaxResults

Maximum number of UsersID to return.

type NextToken

string

param NextToken

Pagingation token to receive the next set of UsersID.

rtype

dict

returns

Response Syntax

{
    'Users': [
        {
            'UserId': 'string',
            'UserStatus': 'ACTIVE'|'UPDATING'|'CREATING'|'CREATED'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • Users (list) --

      List of UsersID associated with the specified collection.

      • (dict) --

        Metadata of the user stored in a collection.

        • UserId (string) --

          A provided ID for the User. Unique within the collection.

        • UserStatus (string) --

          Communicates if the UserID has been updated with latest set of faces to be associated with the UserID.

    • NextToken (string) --

      A pagination token to be used with the subsequent request if the response is truncated.

DeleteFaces (updated) Link ¶
Changes (response)
{'UnsuccessfulFaceDeletions': [{'FaceId': 'string',
                                'Reasons': ['ASSOCIATED_TO_AN_EXISTING_USER | '
                                            'FACE_NOT_FOUND'],
                                'UserId': 'string'}]}

Deletes faces from a collection. You specify a collection ID and an array of face IDs to remove from the collection.

This operation requires permissions to perform the rekognition:DeleteFaces action.

See also: AWS API Documentation

Request Syntax

client.delete_faces(
    CollectionId='string',
    FaceIds=[
        'string',
    ]
)
type CollectionId

string

param CollectionId

[REQUIRED]

Collection from which to remove the specific faces.

type FaceIds

list

param FaceIds

[REQUIRED]

An array of face IDs to delete.

  • (string) --

rtype

dict

returns

Response Syntax

{
    'DeletedFaces': [
        'string',
    ],
    'UnsuccessfulFaceDeletions': [
        {
            'FaceId': 'string',
            'UserId': 'string',
            'Reasons': [
                'ASSOCIATED_TO_AN_EXISTING_USER'|'FACE_NOT_FOUND',
            ]
        },
    ]
}

Response Structure

  • (dict) --

    • DeletedFaces (list) --

      An array of strings (face IDs) of the faces that were deleted.

      • (string) --

    • UnsuccessfulFaceDeletions (list) --

      An array of any faces that weren't deleted.

      • (dict) --

        Contains metadata like FaceId, UserID, and Reasons, for a face that was unsuccessfully deleted.

        • FaceId (string) --

          A unique identifier assigned to the face.

        • UserId (string) --

          A provided ID for the UserID. Unique within the collection.

        • Reasons (list) --

          The reason why the deletion was unsuccessful.

          • (string) --

DescribeCollection (updated) Link ¶
Changes (response)
{'UserCount': 'long'}

Describes the specified collection. You can use DescribeCollection to get information, such as the number of faces indexed into a collection and the version of the model used by the collection for face detection.

For more information, see Describing a Collection in the Amazon Rekognition Developer Guide.

See also: AWS API Documentation

Request Syntax

client.describe_collection(
    CollectionId='string'
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of the collection to describe.

rtype

dict

returns

Response Syntax

{
    'FaceCount': 123,
    'FaceModelVersion': 'string',
    'CollectionARN': 'string',
    'CreationTimestamp': datetime(2015, 1, 1),
    'UserCount': 123
}

Response Structure

  • (dict) --

    • FaceCount (integer) --

      The number of faces that are indexed into the collection. To index faces into a collection, use IndexFaces .

    • FaceModelVersion (string) --

      The version of the face model that's used by the collection for face detection.

      For more information, see Model versioning in the Amazon Rekognition Developer Guide.

    • CollectionARN (string) --

      The Amazon Resource Name (ARN) of the collection.

    • CreationTimestamp (datetime) --

      The number of milliseconds since the Unix epoch time until the creation of the collection. The Unix epoch time is 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970.

    • UserCount (integer) --

      The number of UserIDs assigned to the specified colleciton.

GetFaceSearch (updated) Link ¶
Changes (response)
{'Persons': {'FaceMatches': {'Face': {'UserId': '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'
)
type JobId

string

param JobId

[REQUIRED]

The job identifer for the search request. You get the job identifier from an initial call to StartFaceSearch .

type MaxResults

integer

param MaxResults

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.

type NextToken

string

param NextToken

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.

type SortBy

string

param SortBy

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.

rtype

dict

returns

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': ...,
                    'FaceOccluded': {
                        'Value': True|False,
                        'Confidence': ...
                    },
                    'EyeDirection': {
                        'Yaw': ...,
                        'Pitch': ...,
                        'Confidence': ...
                    }
                }
            },
            'FaceMatches': [
                {
                    'Similarity': ...,
                    'Face': {
                        'FaceId': 'string',
                        'BoundingBox': {
                            'Width': ...,
                            'Height': ...,
                            'Left': ...,
                            'Top': ...
                        },
                        'ImageId': 'string',
                        'ExternalImageId': 'string',
                        'Confidence': ...,
                        'IndexFacesModelVersion': 'string',
                        'UserId': 'string'
                    }
                },
            ]
        },
    ],
    'JobId': 'string',
    'Video': {
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
    'JobTag': '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.

            • FaceOccluded (dict) --

              FaceOccluded should return "true" with a high confidence score if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. FaceOccluded should return "false" with a high confidence score if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

              • Value (boolean) --

                True if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. False if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

              • Confidence (float) --

                The confidence that the service has detected the presence of a face occlusion.

            • EyeDirection (dict) --

              Indicates the direction the eyes are gazing in, as defined by pitch and yaw.

              • Yaw (float) --

                Value representing eye direction on the yaw axis.

              • Pitch (float) --

                Value representing eye direction on the pitch axis.

              • Confidence (float) --

                The confidence that the service has in its predicted eye direction.

        • 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.

              • UserId (string) --

                Unique identifier assigned to the user.

    • JobId (string) --

      Job identifier for the face search operation for which you want to obtain results. The job identifer is returned by an initial call to StartFaceSearch.

    • Video (dict) --

      Video file stored in an Amazon S3 bucket. Amazon Rekognition video start operations such as StartLabelDetection use Video to specify a video for analysis. The supported file formats are .mp4, .mov and .avi.

      • S3Object (dict) --

        The Amazon S3 bucket name and file name for the video.

        • 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.

    • JobTag (string) --

      A job identifier specified in the call to StartFaceSearch and returned in the job completion notification sent to your Amazon Simple Notification Service topic.

IndexFaces (updated) Link ¶
Changes (response)
{'FaceRecords': {'Face': {'UserId': '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 or specific facial attributes (e.g., FACE_OCCLUDED ) by using the detectionAttributes parameter, Amazon Rekognition returns detailed facial attributes, such as facial landmarks (for example, location of eye and mouth), facial occlusion, 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'|'AGE_RANGE'|'BEARD'|'EMOTIONS'|'EYE_DIRECTION'|'EYEGLASSES'|'EYES_OPEN'|'GENDER'|'MOUTH_OPEN'|'MUSTACHE'|'FACE_OCCLUDED'|'SMILE'|'SUNGLASSES',
    ],
    MaxFaces=123,
    QualityFilter='NONE'|'AUTO'|'LOW'|'MEDIUM'|'HIGH'
)
type CollectionId

string

param CollectionId

[REQUIRED]

The ID of an existing collection to which you want to add the faces that are detected in the input images.

type Image

dict

param Image

[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. Note that the maximum image size you can pass to DetectCustomLabels is 4MB.

  • 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.

type ExternalImageId

string

param ExternalImageId

The ID you want to assign to all the faces detected in the image.

type DetectionAttributes

list

param DetectionAttributes

An array of facial attributes you want to be returned. A DEFAULT subset of facial attributes - BoundingBox , Confidence , Pose , Quality , and Landmarks - will always be returned. You can request for specific facial attributes (in addition to the default list) - by using ["DEFAULT", "FACE_OCCLUDED"] or just ["FACE_OCCLUDED"] . You can request for all facial attributes by using ["ALL"] . Requesting more attributes may increase response time.

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) --

type MaxFaces

integer

param MaxFaces

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.

type QualityFilter

string

param QualityFilter

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.

rtype

dict

returns

Response Syntax

{
    'FaceRecords': [
        {
            'Face': {
                'FaceId': 'string',
                'BoundingBox': {
                    'Width': ...,
                    'Height': ...,
                    'Left': ...,
                    'Top': ...
                },
                'ImageId': 'string',
                'ExternalImageId': 'string',
                'Confidence': ...,
                'IndexFacesModelVersion': 'string',
                'UserId': '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': ...,
                'FaceOccluded': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'EyeDirection': {
                    'Yaw': ...,
                    'Pitch': ...,
                    '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': ...,
                'FaceOccluded': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'EyeDirection': {
                    'Yaw': ...,
                    'Pitch': ...,
                    '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.

          • UserId (string) --

            Unique identifier assigned to the user.

        • 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.

          • FaceOccluded (dict) --

            FaceOccluded should return "true" with a high confidence score if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. FaceOccluded should return "false" with a high confidence score if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

            • Value (boolean) --

              True if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. False if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

            • Confidence (float) --

              The confidence that the service has detected the presence of a face occlusion.

          • EyeDirection (dict) --

            Indicates the direction the eyes are gazing in, as defined by pitch and yaw.

            • Yaw (float) --

              Value representing eye direction on the yaw axis.

            • Pitch (float) --

              Value representing eye direction on the pitch axis.

            • Confidence (float) --

              The confidence that the service has in its predicted eye direction.

    • 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 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.

          • FaceOccluded (dict) --

            FaceOccluded should return "true" with a high confidence score if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. FaceOccluded should return "false" with a high confidence score if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

            • Value (boolean) --

              True if a detected face’s eyes, nose, and mouth are partially captured or if they are covered by masks, dark sunglasses, cell phones, hands, or other objects. False if common occurrences that do not impact face verification are detected, such as eye glasses, lightly tinted sunglasses, strands of hair, and others.

            • Confidence (float) --

              The confidence that the service has detected the presence of a face occlusion.

          • EyeDirection (dict) --

            Indicates the direction the eyes are gazing in, as defined by pitch and yaw.

            • Yaw (float) --

              Value representing eye direction on the yaw axis.

            • Pitch (float) --

              Value representing eye direction on the pitch axis.

            • Confidence (float) --

              The confidence that the service has in its predicted eye direction.

ListFaces (updated) Link ¶
Changes (request, response)
Request
{'FaceIds': ['string'], 'UserId': 'string'}
Response
{'Faces': {'UserId': '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,
    UserId='string',
    FaceIds=[
        'string',
    ]
)
type CollectionId

string

param CollectionId

[REQUIRED]

ID of the collection from which to list the faces.

type NextToken

string

param NextToken

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.

type MaxResults

integer

param MaxResults

Maximum number of faces to return.

type UserId

string

param UserId

An array of user IDs to match when listing faces in a collection.

type FaceIds

list

param FaceIds

An array of face IDs to match when listing faces in a collection.

  • (string) --

rtype

dict

returns

Response Syntax

{
    'Faces': [
        {
            'FaceId': 'string',
            'BoundingBox': {
                'Width': ...,
                'Height': ...,
                'Left': ...,
                'Top': ...
            },
            'ImageId': 'string',
            'ExternalImageId': 'string',
            'Confidence': ...,
            'IndexFacesModelVersion': 'string',
            'UserId': '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.

        • UserId (string) --

          Unique identifier assigned to the user.

    • 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) --

      Version number of the face detection model associated with the input collection (CollectionId ).

SearchFaces (updated) Link ¶
Changes (response)
{'FaceMatches': {'Face': {'UserId': '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=...
)
type CollectionId

string

param CollectionId

[REQUIRED]

ID of the collection the face belongs to.

type FaceId

string

param FaceId

[REQUIRED]

ID of a face to find matches for in the collection.

type MaxFaces

integer

param MaxFaces

Maximum number of faces to return. The operation returns the maximum number of faces with the highest confidence in the match.

type FaceMatchThreshold

float

param FaceMatchThreshold

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%.

rtype

dict

returns

Response Syntax

{
    'SearchedFaceId': 'string',
    'FaceMatches': [
        {
            'Similarity': ...,
            'Face': {
                'FaceId': 'string',
                'BoundingBox': {
                    'Width': ...,
                    'Height': ...,
                    'Left': ...,
                    'Top': ...
                },
                'ImageId': 'string',
                'ExternalImageId': 'string',
                'Confidence': ...,
                'IndexFacesModelVersion': 'string',
                'UserId': '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.

          • UserId (string) --

            Unique identifier assigned to the user.

    • FaceModelVersion (string) --

      Version number of the face detection model associated with the input collection (CollectionId ).

SearchFacesByImage (updated) Link ¶
Changes (response)
{'FaceMatches': {'Face': {'UserId': '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'
)
type CollectionId

string

param CollectionId

[REQUIRED]

ID of the collection to search.

type Image

dict

param Image

[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. Note that the maximum image size you can pass to DetectCustomLabels is 4MB.

  • 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.

type MaxFaces

integer

param MaxFaces

Maximum number of faces to return. The operation returns the maximum number of faces with the highest confidence in the match.

type FaceMatchThreshold

float

param FaceMatchThreshold

(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%.

type QualityFilter

string

param QualityFilter

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.

rtype

dict

returns

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',
                'UserId': '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.

          • UserId (string) --

            Unique identifier assigned to the user.

    • FaceModelVersion (string) --

      Version number of the face detection model associated with the input collection (CollectionId ).