Amazon Rekognition

2023/04/10 - Amazon Rekognition - 2 new api methods

Changes  This release adds support for Face Liveness APIs in Amazon Rekognition. Updates UpdateStreamProcessor to return ResourceInUseException Exception. Minor updates to API documentation.

GetFaceLivenessSessionResults (new) Link ¶

Retrieves the results of a specific Face Liveness session. It requires the sessionId as input, which was created using CreateFaceLivenessSession . Returns the corresponding Face Liveness confidence score, a reference image that includes a face bounding box, and audit images that also contain face bounding boxes. The Face Liveness confidence score ranges from 0 to 100. The reference image can optionally be returned.

See also: AWS API Documentation

Request Syntax

client.get_face_liveness_session_results(
    SessionId='string'
)
type SessionId

string

param SessionId

[REQUIRED]

A unique 128-bit UUID. This is used to uniquely identify the session and also acts as an idempotency token for all operations associated with the session.

rtype

dict

returns

Response Syntax

{
    'SessionId': 'string',
    'Status': 'CREATED'|'IN_PROGRESS'|'SUCCEEDED'|'FAILED',
    'Confidence': ...,
    'ReferenceImage': {
        'Bytes': b'bytes',
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        },
        'BoundingBox': {
            'Width': ...,
            'Height': ...,
            'Left': ...,
            'Top': ...
        }
    },
    'AuditImages': [
        {
            'Bytes': b'bytes',
            'S3Object': {
                'Bucket': 'string',
                'Name': 'string',
                'Version': 'string'
            },
            'BoundingBox': {
                'Width': ...,
                'Height': ...,
                'Left': ...,
                'Top': ...
            }
        },
    ]
}

Response Structure

  • (dict) --

    • SessionId (string) --

      The sessionId for which this request was called.

    • Status (string) --

      Represents a status corresponding to the state of the session. Possible statuses are: CREATED, IN_PROGRESS, SUCCEEDED, FAILED, EXPIRED.

    • Confidence (float) --

      Probabalistic confidence score for if the person in the given video was live, represented as a float value between 0 to 100.

    • ReferenceImage (dict) --

      A high-quality image from the Face Liveness video that can be used for face comparison or search. It includes a bounding box of the face and the Base64-encoded bytes that return an image. If the CreateFaceLivenessSession request included an OutputConfig argument, the image will be uploaded to an S3Object specified in the output configuration. In case the reference image is not returned, it's recommended to retry the Liveness check.

      • Bytes (bytes) --

        The Base64-encoded bytes representing an image selected from the Face Liveness video and returned for audit purposes.

      • S3Object (dict) --

        Provides the S3 bucket name and object name.

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

        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.

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

      • BoundingBox (dict) --

        Identifies the bounding box around the label, face, text, object of interest, or personal protective equipment. The left (x-coordinate) and top (y-coordinate) are coordinates representing the top and left sides of the bounding box. Note that the upper-left corner of the image is the origin (0,0).

        The top and left values returned are ratios of the overall image size. For example, if the input image is 700x200 pixels, and the top-left coordinate of the bounding box is 350x50 pixels, the API returns a left value of 0.5 (350/700) and a top value of 0.25 (50/200).

        The width and height values represent the dimensions of the bounding box as a ratio of the overall image dimension. For example, if the input image is 700x200 pixels, and the bounding box width is 70 pixels, the width returned is 0.1.

        Note

        The bounding box coordinates can have negative values. For example, if Amazon Rekognition is able to detect a face that is at the image edge and is only partially visible, the service can return coordinates that are outside the image bounds and, depending on the image edge, you might get negative values or values greater than 1 for the left or top values.

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

    • AuditImages (list) --

      A set of images from the Face Liveness video that can be used for audit purposes. It includes a bounding box of the face and the Base64-encoded bytes that return an image. If the CreateFaceLivenessSession request included an OutputConfig argument, the image will be uploaded to an S3Object specified in the output configuration.

      • (dict) --

        An image that is picked from the Face Liveness video and returned for audit trail purposes, returned as Base64-encoded bytes.

        • Bytes (bytes) --

          The Base64-encoded bytes representing an image selected from the Face Liveness video and returned for audit purposes.

        • S3Object (dict) --

          Provides the S3 bucket name and object name.

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

          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.

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

        • BoundingBox (dict) --

          Identifies the bounding box around the label, face, text, object of interest, or personal protective equipment. The left (x-coordinate) and top (y-coordinate) are coordinates representing the top and left sides of the bounding box. Note that the upper-left corner of the image is the origin (0,0).

          The top and left values returned are ratios of the overall image size. For example, if the input image is 700x200 pixels, and the top-left coordinate of the bounding box is 350x50 pixels, the API returns a left value of 0.5 (350/700) and a top value of 0.25 (50/200).

          The width and height values represent the dimensions of the bounding box as a ratio of the overall image dimension. For example, if the input image is 700x200 pixels, and the bounding box width is 70 pixels, the width returned is 0.1.

          Note

          The bounding box coordinates can have negative values. For example, if Amazon Rekognition is able to detect a face that is at the image edge and is only partially visible, the service can return coordinates that are outside the image bounds and, depending on the image edge, you might get negative values or values greater than 1 for the left or top values.

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

CreateFaceLivenessSession (new) Link ¶

This API operation initiates a Face Liveness session. It returns a SessionId , which you can use to start streaming Face Liveness video and get the results for a Face Liveness session. You can use the OutputConfig option in the Settings parameter to provide an Amazon S3 bucket location. The Amazon S3 bucket stores reference images and audit images. You can use AuditImagesLimit to limit of audit images returned. This number is between 0 and 4. By default, it is set to 0. The limit is best effort and based on the duration of the selfie-video.

See also: AWS API Documentation

Request Syntax

client.create_face_liveness_session(
    KmsKeyId='string',
    Settings={
        'OutputConfig': {
            'S3Bucket': 'string',
            'S3KeyPrefix': 'string'
        },
        'AuditImagesLimit': 123
    },
    ClientRequestToken='string'
)
type KmsKeyId

string

param KmsKeyId

The identifier for your AWS Key Management Service key (AWS KMS key). Used to encrypt audit images and reference images.

type Settings

dict

param Settings

A session settings object. It contains settings for the operation to be performed. For Face Liveness, it accepts OutputConfig and AuditImagesLimit .

  • OutputConfig (dict) --

    Can specify the location of an Amazon S3 bucket, where reference and audit images will be stored. Note that the Amazon S3 bucket must be located in the caller's AWS account and in the same region as the Face Liveness end-point. Additionally, the Amazon S3 object keys are auto-generated by the Face Liveness system.

    • S3Bucket (string) -- [REQUIRED]

      The path to an AWS Amazon S3 bucket used to store Face Liveness session results.

    • S3KeyPrefix (string) --

      The prefix appended to the output files for the Face Liveness session results.

  • AuditImagesLimit (integer) --

    Number of audit images to be returned back. Takes an integer between 0-4. Any integer less than 0 will return 0, any integer above 4 will return 4 images in the response. By default, it is set to 0. The limit is best effort and is based on the actual duration of the selfie-video.

type ClientRequestToken

string

param ClientRequestToken

Idempotent token is used to recognize the Face Liveness request. If the same token is used with multiple CreateFaceLivenessSession requests, the same session is returned. This token is employed to avoid unintentionally creating the same session multiple times.

rtype

dict

returns

Response Syntax

{
    'SessionId': 'string'
}

Response Structure

  • (dict) --

    • SessionId (string) --

      A unique 128-bit UUID identifying a Face Liveness session.