Search in sources :

Example 1 with DetectCustomLabelsResponse

use of software.amazon.awssdk.services.rekognition.model.DetectCustomLabelsResponse in project aws-doc-sdk-examples by awsdocs.

the class DetectCustomLabels method detectImageCustomLabels.

public static void detectImageCustomLabels(RekognitionClient rekClient, String arn, String bucket, String key) {
    try {
        S3Object s3Object = S3Object.builder().bucket(bucket).name(key).build();
        // Create an Image object for the source image
        Image s3Image = Image.builder().s3Object(s3Object).build();
        DetectCustomLabelsRequest detectCustomLabelsRequest = DetectCustomLabelsRequest.builder().image(s3Image).projectVersionArn(arn).build();
        DetectCustomLabelsResponse customLabelsResponse = rekClient.detectCustomLabels(detectCustomLabelsRequest);
        List<CustomLabel> customLabels = customLabelsResponse.customLabels();
        System.out.println("Detected labels for the given photo");
        for (CustomLabel customLabel : customLabels) {
            System.out.println(customLabel.name() + ": " + customLabel.confidence().toString());
        }
    } catch (RekognitionException e) {
        System.out.println(e.getMessage());
        System.exit(1);
    }
}
Also used : CustomLabel(software.amazon.awssdk.services.rekognition.model.CustomLabel) RekognitionException(software.amazon.awssdk.services.rekognition.model.RekognitionException) S3Object(software.amazon.awssdk.services.rekognition.model.S3Object) DetectCustomLabelsResponse(software.amazon.awssdk.services.rekognition.model.DetectCustomLabelsResponse) Image(software.amazon.awssdk.services.rekognition.model.Image) DetectCustomLabelsRequest(software.amazon.awssdk.services.rekognition.model.DetectCustomLabelsRequest)

Aggregations

CustomLabel (software.amazon.awssdk.services.rekognition.model.CustomLabel)1 DetectCustomLabelsRequest (software.amazon.awssdk.services.rekognition.model.DetectCustomLabelsRequest)1 DetectCustomLabelsResponse (software.amazon.awssdk.services.rekognition.model.DetectCustomLabelsResponse)1 Image (software.amazon.awssdk.services.rekognition.model.Image)1 RekognitionException (software.amazon.awssdk.services.rekognition.model.RekognitionException)1 S3Object (software.amazon.awssdk.services.rekognition.model.S3Object)1