AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

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

Amazon Rekognition does not save the actual faces detected. Instead, the underlying detection algorithm first detects the faces in the input image, and for each face extracts facial features into a feature vector, and stores it in the back-end database. Amazon Rekognition uses feature vectors when performing face match and search operations using the and operations.

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

In response, the operation returns an array of metadata for all detected faces. This includes, the bounding box of the detected face, confidence value (indicating the bounding box contains a face), a face ID assigned by the service for each face that is detected and stored, and an image ID assigned by the service for the input image. If you request all facial attributes (using the detectionAttributes parameter, Amazon Rekognition returns detailed facial attributes such as facial landmarks (for example, location of eye and mount) and other facial attributes such gender. 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.

For an example, see example2.

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

Note:

For PCL this operation is only available in asynchronous form. Please refer to IndexFacesAsync.

Namespace: Amazon.Rekognition
Assembly: AWSSDK.Rekognition.dll
Version: 3.x.y.z

Syntax

C#
public abstract IndexFacesResponse IndexFaces(
         IndexFacesRequest request
)
Parameters
request
Type: Amazon.Rekognition.Model.IndexFacesRequest

Container for the necessary parameters to execute the IndexFaces service method.

Return Value
The response from the IndexFaces service method, as returned by Rekognition.

Exceptions

ExceptionCondition
AccessDeniedException You are not authorized to perform the action.
ImageTooLargeException The input image size exceeds the allowed limit. For more information, see limits.
InternalServerErrorException Amazon Rekognition experienced a service issue. Try your call again.
InvalidImageFormatException The provided image format is not supported.
InvalidParameterException Input parameter violated a constraint. Validate your parameter before calling the API operation again.
InvalidS3ObjectException Amazon Rekognition is unable to access the S3 object specified in the request.
ProvisionedThroughputExceededException The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.
ResourceNotFoundException Collection specified in the request is not found.
ThrottlingException Amazon Rekognition is temporarily unable to process the request. Try your call again.

Examples

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

To add a face to a collection


var response = client.IndexFaces(new IndexFacesRequest 
{
    CollectionId = "myphotos",
    DetectionAttributes = new List {
                    
    },
    ExternalImageId = "myphotoid",
    Image = new Image { S3Object = new S3Object {
        Bucket = "mybucket",
        Name = "myphoto"
    } }
});

List faceRecords = response.FaceRecords;
string orientationCorrection = response.OrientationCorrection;

            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

See Also