use of software.amazon.awssdk.services.rekognition.model.DetectCustomLabelsRequest 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);
}
}
Aggregations