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 instances of real-world entities within an image (JPEG or PNG) provided as input. This includes objects like flower, tree, and table; events like wedding, graduation, and birthday party; and concepts like landscape, evening, and nature.

For an example, see Analyzing images stored in an Amazon S3 bucket in the Amazon Rekognition Developer Guide.

You pass the input image 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.

Optional Parameters

You can specify one or both of the GENERAL_LABELS and IMAGE_PROPERTIES feature types when calling the DetectLabels API. Including GENERAL_LABELS will ensure the response includes the labels detected in the input image, while including IMAGE_PROPERTIES will ensure the response includes information about the image quality and color.

When using GENERAL_LABELS and/or IMAGE_PROPERTIES you can provide filtering criteria to the Settings parameter. You can filter with sets of individual labels or with label categories. You can specify inclusive filters, exclusive filters, or a combination of inclusive and exclusive filters. For more information on filtering see Detecting Labels in an Image.

When getting labels, you can specify MinConfidence to control the confidence threshold for the labels returned. The default is 55%. You can also add the MaxLabels parameter to limit the number of labels returned. The default and upper limit is 1000 labels. These arguments are only valid when supplying GENERAL_LABELS as a feature type.

Response Elements

For each object, scene, and concept the API returns one or more labels. The API returns the following types of information about labels:

The API returns the following information regarding the image, as part of the ImageProperties structure:

The list of returned labels will include at least one label for every detected object, along with information about that label. In the following example, suppose the input image has a lighthouse, the sea, and a rock. The response includes all three labels, one for each object, as well as the confidence in the label:

{Name: lighthouse, Confidence: 98.4629}

{Name: rock,Confidence: 79.2097}

{Name: sea,Confidence: 75.061}

The list of labels can include multiple labels for the same object. For example, if the input image shows a flower (for example, a tulip), the operation might return the following three labels.

{Name: flower,Confidence: 99.0562}

{Name: plant,Confidence: 99.0562}

{Name: tulip,Confidence: 99.0562}

In this example, the detection algorithm more precisely identifies the flower as a tulip.

If the object detected is a person, the operation doesn't provide the same facial details that the DetectFaces operation provides.

This is a stateless API operation that doesn't return any data.

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

Note:

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

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

Syntax

C#
public abstract DetectLabelsResponse DetectLabels(
         DetectLabelsRequest request
)

Parameters

request
Type: Amazon.Rekognition.Model.DetectLabelsRequest

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

Return Value


The response from the DetectLabels 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 labels in the supplied image

To detect labels


var client = new AmazonRekognitionClient();
var response = client.DetectLabels(new DetectLabelsRequest 
{
    Image = new Image { S3Object = new S3Object {
        Bucket = "mybucket",
        Name = "myphoto"
    } },
    MaxLabels = 123,
    MinConfidence = 70
});

List<Label> labels = response.Labels;

            

Version Information

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

See Also