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 are 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. To determine which version of the model you are using, check the 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 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 more information, see Adding Faces to a Collection in the Amazon Rekognition Developer Guide.

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 Amazon CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.

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


For .NET Core and 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


public virtual IndexFacesResponse IndexFaces(
         IndexFacesRequest 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.


AccessDeniedException You are not authorized to perform the action.
ImageTooLargeException The input image size exceeds the allowed limit. For more information, see Limits in Amazon Rekognition in the Amazon Rekognition Developer Guide.
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 The collection specified in the request cannot be found.
ThrottlingException Amazon Rekognition is temporarily unable to process the request. Try your call again.


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