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 within an image that is provided as input.

DetectFaces detects the 100 largest faces in the image. For each face detected, the operation returns face details. These details include a bounding box of the face, a confidence value (that the bounding box contains a face), and a fixed set of attributes such as facial landmarks (for example, coordinates of eye and mouth), pose, presence of facial occlusion, and so on.

The face-detection algorithm is most effective on frontal faces. For non-frontal or obscured faces, the algorithm might not detect the faces or might detect faces with lower confidence.

You pass the input image 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 is not supported. The image must be either a PNG or JPEG formatted file.

This is a stateless API operation. That is, the operation does not persist any data.

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

Note:

For .NET Core this operation is only available in asynchronous form. Please refer to DetectFacesAsync.

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

Syntax

C#
public virtual DetectFacesResponse DetectFaces(
         DetectFacesRequest request
)

Parameters

request
Type: Amazon.Rekognition.Model.DetectFacesRequest

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

Return Value


The response from the DetectFaces 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. If you are calling DetectProtectiveEquipment, the image size or resolution exceeds the allowed limit. For more information, see Guidelines and quotas 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.
ThrottlingException Amazon Rekognition is temporarily unable to process the request. Try your call again.

Examples

This operation detects faces in an image stored in an AWS S3 bucket.

To detect faces in an image


var client = new AmazonRekognitionClient();
var response = client.DetectFaces(new DetectFacesRequest 
{
    Image = new Image { S3Object = new S3Object {
        Bucket = "mybucket",
        Name = "myphoto"
    } }
});

List<FaceDetail> faceDetails = response.FaceDetails;
string orientationCorrection = response.OrientationCorrection;

            

Version Information

.NET Framework:
Supported in: 4.5 and newer, 3.5

See Also