index_faces

index_faces(**kwargs)

Detects faces in the input image and adds them to the specified collection.

Amazon Rekognition doesn't save the actual faces that are detected. Instead, the underlying detection algorithm first detects the faces in the input image. For each face, the algorithm extracts facial features into a feature vector, and stores it in the backend database. Amazon Rekognition uses feature vectors when it performs face match and search operations using the SearchFaces and SearchFacesByImage operations.

For more information, see Adding faces to a collection in the Amazon Rekognition Developer Guide.

To get the number of faces in a collection, call DescribeCollection.

If you're using version 1.0 of the face detection model, IndexFaces indexes the 15 largest faces in the input image. Later versions of the face detection model index the 100 largest faces in the input image.

If you're using version 4 or later of the face model, image orientation information is not returned in the OrientationCorrection field.

To determine which version of the model you're using, call DescribeCollection and supply the collection ID. You can also get the model version from the value of FaceModelVersion in the response from IndexFaces

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

If you provide the optional ExternalImageId for the input image you provided, Amazon Rekognition associates this ID with all faces that it detects. When you call the ListFaces operation, the response returns the external ID. You can use this external image ID to create a client-side index to associate the faces with each image. You can then use the index to find all faces in an image.

You can specify the maximum number of faces to index with the MaxFaces input parameter. This is useful when you want to index the largest faces in an image and don't want to index smaller faces, such as those belonging to people standing in the background.

The QualityFilter input parameter allows you to filter out detected faces that don’t meet a required quality bar. The quality bar is based on a variety of common use cases. By default, IndexFaces chooses the quality bar that's used to filter faces. You can also explicitly choose the quality bar. Use QualityFilter , to set the quality bar by specifying LOW , MEDIUM , or HIGH . If you do not want to filter detected faces, specify NONE .

Note

To use quality filtering, you need a collection associated with version 3 of the face model or higher. To get the version of the face model associated with a collection, call DescribeCollection.

Information about faces detected in an image, but not indexed, is returned in an array of UnindexedFace objects, UnindexedFaces . Faces aren't indexed for reasons such as:

  • The number of faces detected exceeds the value of the MaxFaces request parameter.
  • The face is too small compared to the image dimensions.
  • The face is too blurry.
  • The image is too dark.
  • The face has an extreme pose.
  • The face doesn’t have enough detail to be suitable for face search.

In response, the IndexFaces operation returns an array of metadata for all detected faces, FaceRecords . This includes:

  • The bounding box, BoundingBox , of the detected face.
  • A confidence value, Confidence , which indicates the confidence that the bounding box contains a face.
  • A face ID, FaceId , assigned by the service for each face that's detected and stored.
  • An image ID, ImageId , assigned by the service for the input image.

If you request all facial attributes (by using the detectionAttributes parameter), Amazon Rekognition returns detailed facial attributes, such as facial landmarks (for example, location of eye and mouth) and other facial attributes. If you provide the same image, specify the same collection, and use the same external ID in the IndexFaces operation, Amazon Rekognition doesn't save duplicate face metadata.

The input image is passed either as base64-encoded image bytes, or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes isn't supported. The image must be formatted as a PNG or JPEG file.

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

See also: AWS API Documentation

Request Syntax

response = client.index_faces(
    CollectionId='string',
    Image={
        'Bytes': b'bytes',
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
    ExternalImageId='string',
    DetectionAttributes=[
        'DEFAULT'|'ALL',
    ],
    MaxFaces=123,
    QualityFilter='NONE'|'AUTO'|'LOW'|'MEDIUM'|'HIGH'
)
Parameters
  • CollectionId (string) --

    [REQUIRED]

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

  • Image (dict) --

    [REQUIRED]

    The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing base64-encoded image bytes isn't supported.

    If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the Bytes field. For more information, see Images in the Amazon Rekognition developer guide.

    • Bytes (bytes) --

      Blob of image bytes up to 5 MBs.

    • S3Object (dict) --

      Identifies an S3 object as the image source.

      • Bucket (string) --

        Name of the S3 bucket.

      • Name (string) --

        S3 object key name.

      • Version (string) --

        If the bucket is versioning enabled, you can specify the object version.

  • ExternalImageId (string) -- The ID you want to assign to all the faces detected in the image.
  • DetectionAttributes (list) --

    An array of facial attributes that you want to be returned. This can be the default list of attributes or all attributes. If you don't specify a value for Attributes or if you specify ["DEFAULT"] , the API returns the following subset of facial attributes: BoundingBox , Confidence , Pose , Quality , and Landmarks . If you provide ["ALL"] , all facial attributes are returned, but the operation takes longer to complete.

    If you provide both, ["ALL", "DEFAULT"] , the service uses a logical AND operator to determine which attributes to return (in this case, all attributes).

    • (string) --
  • MaxFaces (integer) --

    The maximum number of faces to index. The value of MaxFaces must be greater than or equal to 1. IndexFaces returns no more than 100 detected faces in an image, even if you specify a larger value for MaxFaces .

    If IndexFaces detects more faces than the value of MaxFaces , the faces with the lowest quality are filtered out first. If there are still more faces than the value of MaxFaces , the faces with the smallest bounding boxes are filtered out (up to the number that's needed to satisfy the value of MaxFaces ). Information about the unindexed faces is available in the UnindexedFaces array.

    The faces that are returned by IndexFaces are sorted by the largest face bounding box size to the smallest size, in descending order.

    MaxFaces can be used with a collection associated with any version of the face model.
  • QualityFilter (string) --

    A filter that specifies a quality bar for how much filtering is done to identify faces. Filtered faces aren't indexed. If you specify AUTO , Amazon Rekognition chooses the quality bar. If you specify LOW , MEDIUM , or HIGH , filtering removes all faces that don’t meet the chosen quality bar. The default value is AUTO . The quality bar is based on a variety of common use cases. Low-quality detections can occur for a number of reasons. Some examples are an object that's misidentified as a face, a face that's too blurry, or a face with a pose that's too extreme to use. If you specify NONE , no filtering is performed.

    To use quality filtering, the collection you are using must be associated with version 3 of the face model or higher.

Return type

dict

Returns

Response Syntax

{
    'FaceRecords': [
        {
            'Face': {
                'FaceId': 'string',
                'BoundingBox': {
                    'Width': ...,
                    'Height': ...,
                    'Left': ...,
                    'Top': ...
                },
                'ImageId': 'string',
                'ExternalImageId': 'string',
                'Confidence': ...,
                'IndexFacesModelVersion': 'string'
            },
            'FaceDetail': {
                'BoundingBox': {
                    'Width': ...,
                    'Height': ...,
                    'Left': ...,
                    'Top': ...
                },
                'AgeRange': {
                    'Low': 123,
                    'High': 123
                },
                'Smile': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Eyeglasses': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Sunglasses': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Gender': {
                    'Value': 'Male'|'Female',
                    'Confidence': ...
                },
                'Beard': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Mustache': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'EyesOpen': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'MouthOpen': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Emotions': [
                    {
                        'Type': 'HAPPY'|'SAD'|'ANGRY'|'CONFUSED'|'DISGUSTED'|'SURPRISED'|'CALM'|'UNKNOWN'|'FEAR',
                        'Confidence': ...
                    },
                ],
                'Landmarks': [
                    {
                        'Type': 'eyeLeft'|'eyeRight'|'nose'|'mouthLeft'|'mouthRight'|'leftEyeBrowLeft'|'leftEyeBrowRight'|'leftEyeBrowUp'|'rightEyeBrowLeft'|'rightEyeBrowRight'|'rightEyeBrowUp'|'leftEyeLeft'|'leftEyeRight'|'leftEyeUp'|'leftEyeDown'|'rightEyeLeft'|'rightEyeRight'|'rightEyeUp'|'rightEyeDown'|'noseLeft'|'noseRight'|'mouthUp'|'mouthDown'|'leftPupil'|'rightPupil'|'upperJawlineLeft'|'midJawlineLeft'|'chinBottom'|'midJawlineRight'|'upperJawlineRight',
                        'X': ...,
                        'Y': ...
                    },
                ],
                'Pose': {
                    'Roll': ...,
                    'Yaw': ...,
                    'Pitch': ...
                },
                'Quality': {
                    'Brightness': ...,
                    'Sharpness': ...
                },
                'Confidence': ...
            }
        },
    ],
    'OrientationCorrection': 'ROTATE_0'|'ROTATE_90'|'ROTATE_180'|'ROTATE_270',
    'FaceModelVersion': 'string',
    'UnindexedFaces': [
        {
            'Reasons': [
                'EXCEEDS_MAX_FACES'|'EXTREME_POSE'|'LOW_BRIGHTNESS'|'LOW_SHARPNESS'|'LOW_CONFIDENCE'|'SMALL_BOUNDING_BOX'|'LOW_FACE_QUALITY',
            ],
            'FaceDetail': {
                'BoundingBox': {
                    'Width': ...,
                    'Height': ...,
                    'Left': ...,
                    'Top': ...
                },
                'AgeRange': {
                    'Low': 123,
                    'High': 123
                },
                'Smile': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Eyeglasses': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Sunglasses': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Gender': {
                    'Value': 'Male'|'Female',
                    'Confidence': ...
                },
                'Beard': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Mustache': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'EyesOpen': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'MouthOpen': {
                    'Value': True|False,
                    'Confidence': ...
                },
                'Emotions': [
                    {
                        'Type': 'HAPPY'|'SAD'|'ANGRY'|'CONFUSED'|'DISGUSTED'|'SURPRISED'|'CALM'|'UNKNOWN'|'FEAR',
                        'Confidence': ...
                    },
                ],
                'Landmarks': [
                    {
                        'Type': 'eyeLeft'|'eyeRight'|'nose'|'mouthLeft'|'mouthRight'|'leftEyeBrowLeft'|'leftEyeBrowRight'|'leftEyeBrowUp'|'rightEyeBrowLeft'|'rightEyeBrowRight'|'rightEyeBrowUp'|'leftEyeLeft'|'leftEyeRight'|'leftEyeUp'|'leftEyeDown'|'rightEyeLeft'|'rightEyeRight'|'rightEyeUp'|'rightEyeDown'|'noseLeft'|'noseRight'|'mouthUp'|'mouthDown'|'leftPupil'|'rightPupil'|'upperJawlineLeft'|'midJawlineLeft'|'chinBottom'|'midJawlineRight'|'upperJawlineRight',
                        'X': ...,
                        'Y': ...
                    },
                ],
                'Pose': {
                    'Roll': ...,
                    'Yaw': ...,
                    'Pitch': ...
                },
                'Quality': {
                    'Brightness': ...,
                    'Sharpness': ...
                },
                'Confidence': ...
            }
        },
    ]
}

Response Structure

  • (dict) --

    • FaceRecords (list) --

      An array of faces detected and added to the collection. For more information, see Searching Faces in a Collection in the Amazon Rekognition Developer Guide.

      • (dict) --

        Object containing both the face metadata (stored in the backend database), and facial attributes that are detected but aren't stored in the database.

        • Face (dict) --

          Describes the face properties such as the bounding box, face ID, image ID of the input image, and external image ID that you assigned.

          • FaceId (string) --

            Unique identifier that Amazon Rekognition assigns to the face.

          • BoundingBox (dict) --

            Bounding box of the face.

            • Width (float) --

              Width of the bounding box as a ratio of the overall image width.

            • Height (float) --

              Height of the bounding box as a ratio of the overall image height.

            • Left (float) --

              Left coordinate of the bounding box as a ratio of overall image width.

            • Top (float) --

              Top coordinate of the bounding box as a ratio of overall image height.

          • ImageId (string) --

            Unique identifier that Amazon Rekognition assigns to the input image.

          • ExternalImageId (string) --

            Identifier that you assign to all the faces in the input image.

          • Confidence (float) --

            Confidence level that the bounding box contains a face (and not a different object such as a tree).

          • IndexFacesModelVersion (string) --

            The version of the face detect and storage model that was used when indexing the face vector.

        • FaceDetail (dict) --

          Structure containing attributes of the face that the algorithm detected.

          • BoundingBox (dict) --

            Bounding box of the face. Default attribute.

            • Width (float) --

              Width of the bounding box as a ratio of the overall image width.

            • Height (float) --

              Height of the bounding box as a ratio of the overall image height.

            • Left (float) --

              Left coordinate of the bounding box as a ratio of overall image width.

            • Top (float) --

              Top coordinate of the bounding box as a ratio of overall image height.

          • AgeRange (dict) --

            The estimated age range, in years, for the face. Low represents the lowest estimated age and High represents the highest estimated age.

            • Low (integer) --

              The lowest estimated age.

            • High (integer) --

              The highest estimated age.

          • Smile (dict) --

            Indicates whether or not the face is smiling, and the confidence level in the determination.

            • Value (boolean) --

              Boolean value that indicates whether the face is smiling or not.

            • Confidence (float) --

              Level of confidence in the determination.

          • Eyeglasses (dict) --

            Indicates whether or not the face is wearing eye glasses, and the confidence level in the determination.

            • Value (boolean) --

              Boolean value that indicates whether the face is wearing eye glasses or not.

            • Confidence (float) --

              Level of confidence in the determination.

          • Sunglasses (dict) --

            Indicates whether or not the face is wearing sunglasses, and the confidence level in the determination.

            • Value (boolean) --

              Boolean value that indicates whether the face is wearing sunglasses or not.

            • Confidence (float) --

              Level of confidence in the determination.

          • Gender (dict) --

            The predicted gender of a detected face.

            • Value (string) --

              The predicted gender of the face.

            • Confidence (float) --

              Level of confidence in the prediction.

          • Beard (dict) --

            Indicates whether or not the face has a beard, and the confidence level in the determination.

            • Value (boolean) --

              Boolean value that indicates whether the face has beard or not.

            • Confidence (float) --

              Level of confidence in the determination.

          • Mustache (dict) --

            Indicates whether or not the face has a mustache, and the confidence level in the determination.

            • Value (boolean) --

              Boolean value that indicates whether the face has mustache or not.

            • Confidence (float) --

              Level of confidence in the determination.

          • EyesOpen (dict) --

            Indicates whether or not the eyes on the face are open, and the confidence level in the determination.

            • Value (boolean) --

              Boolean value that indicates whether the eyes on the face are open.

            • Confidence (float) --

              Level of confidence in the determination.

          • MouthOpen (dict) --

            Indicates whether or not the mouth on the face is open, and the confidence level in the determination.

            • Value (boolean) --

              Boolean value that indicates whether the mouth on the face is open or not.

            • Confidence (float) --

              Level of confidence in the determination.

          • Emotions (list) --

            The emotions that appear to be expressed on the face, and the confidence level in the determination. The API is only making a determination of the physical appearance of a person's face. It is not a determination of the person’s internal emotional state and should not be used in such a way. For example, a person pretending to have a sad face might not be sad emotionally.

            • (dict) --

              The emotions that appear to be expressed on the face, and the confidence level in the determination. The API is only making a determination of the physical appearance of a person's face. It is not a determination of the person’s internal emotional state and should not be used in such a way. For example, a person pretending to have a sad face might not be sad emotionally.

              • Type (string) --

                Type of emotion detected.

              • Confidence (float) --

                Level of confidence in the determination.

          • Landmarks (list) --

            Indicates the location of landmarks on the face. Default attribute.

            • (dict) --

              Indicates the location of the landmark on the face.

              • Type (string) --

                Type of landmark.

              • X (float) --

                The x-coordinate of the landmark expressed as a ratio of the width of the image. The x-coordinate is measured from the left-side of the image. For example, if the image is 700 pixels wide and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.

              • Y (float) --

                The y-coordinate of the landmark expressed as a ratio of the height of the image. The y-coordinate is measured from the top of the image. For example, if the image height is 200 pixels and the y-coordinate of the landmark is at 50 pixels, this value is 0.25.

          • Pose (dict) --

            Indicates the pose of the face as determined by its pitch, roll, and yaw. Default attribute.

            • Roll (float) --

              Value representing the face rotation on the roll axis.

            • Yaw (float) --

              Value representing the face rotation on the yaw axis.

            • Pitch (float) --

              Value representing the face rotation on the pitch axis.

          • Quality (dict) --

            Identifies image brightness and sharpness. Default attribute.

            • Brightness (float) --

              Value representing brightness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a brighter face image.

            • Sharpness (float) --

              Value representing sharpness of the face. The service returns a value between 0 and 100 (inclusive). A higher value indicates a sharper face image.

          • Confidence (float) --

            Confidence level that the bounding box contains a face (and not a different object such as a tree). Default attribute.

    • OrientationCorrection (string) --

      If your collection is associated with a face detection model that's later than version 3.0, the value of OrientationCorrection is always null and no orientation information is returned.

      If your collection is associated with a face detection model that's version 3.0 or earlier, the following applies:

      • If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata that includes the image's orientation. Amazon Rekognition uses this orientation information to perform image correction - the bounding box coordinates are translated to represent object locations after the orientation information in the Exif metadata is used to correct the image orientation. Images in .png format don't contain Exif metadata. The value of OrientationCorrection is null.
      • If the image doesn't contain orientation information in its Exif metadata, Amazon Rekognition returns an estimated orientation (ROTATE_0, ROTATE_90, ROTATE_180, ROTATE_270). Amazon Rekognition doesn’t perform image correction for images. The bounding box coordinates aren't translated and represent the object locations before the image is rotated.

      Bounding box information is returned in the FaceRecords array. You can get the version of the face detection model by calling DescribeCollection.

    • FaceModelVersion (string) --

      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.

Exceptions

  • Rekognition.Client.exceptions.InvalidS3ObjectException
  • Rekognition.Client.exceptions.InvalidParameterException
  • Rekognition.Client.exceptions.ImageTooLargeException
  • Rekognition.Client.exceptions.AccessDeniedException
  • Rekognition.Client.exceptions.InternalServerError
  • Rekognition.Client.exceptions.ThrottlingException
  • Rekognition.Client.exceptions.ProvisionedThroughputExceededException
  • Rekognition.Client.exceptions.ResourceNotFoundException
  • Rekognition.Client.exceptions.InvalidImageFormatException
  • Rekognition.Client.exceptions.ServiceQuotaExceededException

Examples

This operation detects faces in an image and adds them to the specified Rekognition collection.

response = client.index_faces(
    CollectionId='myphotos',
    DetectionAttributes=[
    ],
    ExternalImageId='myphotoid',
    Image={
        'S3Object': {
            'Bucket': 'mybucket',
            'Name': 'myphoto',
        },
    },
)

print(response)

Expected Output:

{
    'FaceRecords': [
        {
            'Face': {
                'BoundingBox': {
                    'Height': 0.33481481671333313,
                    'Left': 0.31888890266418457,
                    'Top': 0.4933333396911621,
                    'Width': 0.25,
                },
                'Confidence': 99.9991226196289,
                'FaceId': 'ff43d742-0c13-5d16-a3e8-03d3f58e980b',
                'ImageId': '465f4e93-763e-51d0-b030-b9667a2d94b1',
            },
            'FaceDetail': {
                'BoundingBox': {
                    'Height': 0.33481481671333313,
                    'Left': 0.31888890266418457,
                    'Top': 0.4933333396911621,
                    'Width': 0.25,
                },
                'Confidence': 99.9991226196289,
                'Landmarks': [
                    {
                        'Type': 'eyeLeft',
                        'X': 0.3976764678955078,
                        'Y': 0.6248345971107483,
                    },
                    {
                        'Type': 'eyeRight',
                        'X': 0.4810936450958252,
                        'Y': 0.6317117214202881,
                    },
                    {
                        'Type': 'noseLeft',
                        'X': 0.41986238956451416,
                        'Y': 0.7111940383911133,
                    },
                    {
                        'Type': 'mouthDown',
                        'X': 0.40525302290916443,
                        'Y': 0.7497701048851013,
                    },
                    {
                        'Type': 'mouthUp',
                        'X': 0.4753248989582062,
                        'Y': 0.7558549642562866,
                    },
                ],
                'Pose': {
                    'Pitch': -9.713645935058594,
                    'Roll': 4.707281112670898,
                    'Yaw': -24.438663482666016,
                },
                'Quality': {
                    'Brightness': 29.23358917236328,
                    'Sharpness': 80,
                },
            },
        },
        {
            'Face': {
                'BoundingBox': {
                    'Height': 0.32592591643333435,
                    'Left': 0.5144444704055786,
                    'Top': 0.15111111104488373,
                    'Width': 0.24444444477558136,
                },
                'Confidence': 99.99950408935547,
                'FaceId': '8be04dba-4e58-520d-850e-9eae4af70eb2',
                'ImageId': '465f4e93-763e-51d0-b030-b9667a2d94b1',
            },
            'FaceDetail': {
                'BoundingBox': {
                    'Height': 0.32592591643333435,
                    'Left': 0.5144444704055786,
                    'Top': 0.15111111104488373,
                    'Width': 0.24444444477558136,
                },
                'Confidence': 99.99950408935547,
                'Landmarks': [
                    {
                        'Type': 'eyeLeft',
                        'X': 0.6006892323493958,
                        'Y': 0.290842205286026,
                    },
                    {
                        'Type': 'eyeRight',
                        'X': 0.6808141469955444,
                        'Y': 0.29609042406082153,
                    },
                    {
                        'Type': 'noseLeft',
                        'X': 0.6395332217216492,
                        'Y': 0.3522595763206482,
                    },
                    {
                        'Type': 'mouthDown',
                        'X': 0.5892083048820496,
                        'Y': 0.38689887523651123,
                    },
                    {
                        'Type': 'mouthUp',
                        'X': 0.674560010433197,
                        'Y': 0.394125759601593,
                    },
                ],
                'Pose': {
                    'Pitch': -4.683138370513916,
                    'Roll': 2.1029529571533203,
                    'Yaw': 6.716655254364014,
                },
                'Quality': {
                    'Brightness': 34.951698303222656,
                    'Sharpness': 160,
                },
            },
        },
    ],
    'OrientationCorrection': 'ROTATE_0',
    'ResponseMetadata': {
        '...': '...',
    },
}