Rekognition / Client / search_users_by_image

search_users_by_image#

Rekognition.Client.search_users_by_image(**kwargs)#

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

response = 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'
)
Parameters:
  • CollectionId (string) –

    [REQUIRED]

    The ID of an existing collection containing the UserID.

  • Image (dict) –

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

  • UserMatchThreshold (float) – Specifies the minimum confidence in the UserID match to return. Default value is 80.

  • MaxUsers (integer) – Maximum number of UserIDs to return.

  • QualityFilter (string) – A filter that specifies a quality bar for how much filtering is done to identify faces. Filtered faces aren’t searched for in the collection. The default value is NONE.

Return type:

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

Exceptions

  • Rekognition.Client.exceptions.InvalidParameterException

  • Rekognition.Client.exceptions.ResourceNotFoundException

  • Rekognition.Client.exceptions.InvalidImageFormatException

  • Rekognition.Client.exceptions.InvalidS3ObjectException

  • Rekognition.Client.exceptions.ImageTooLargeException

  • Rekognition.Client.exceptions.ProvisionedThroughputExceededException

  • Rekognition.Client.exceptions.AccessDeniedException

  • Rekognition.Client.exceptions.InternalServerError

  • Rekognition.Client.exceptions.ThrottlingException