use of software.amazon.awssdk.services.rekognition.model.S3Object in project aws-doc-sdk-examples by awsdocs.
the class VideoCelebrityDetection method StartCelebrityDetection.
// snippet-start:[rekognition.java2.recognize_video_celebrity.main]
public static void StartCelebrityDetection(RekognitionClient rekClient, NotificationChannel channel, String bucket, String video) {
try {
S3Object s3Obj = S3Object.builder().bucket(bucket).name(video).build();
Video vidOb = Video.builder().s3Object(s3Obj).build();
StartCelebrityRecognitionRequest recognitionRequest = StartCelebrityRecognitionRequest.builder().jobTag("Celebrities").notificationChannel(channel).video(vidOb).build();
StartCelebrityRecognitionResponse startCelebrityRecognitionResult = rekClient.startCelebrityRecognition(recognitionRequest);
startJobId = startCelebrityRecognitionResult.jobId();
} catch (RekognitionException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.rekognition.model.S3Object in project aws-doc-sdk-examples by awsdocs.
the class VideoDetect method startLabels.
// snippet-start:[rekognition.java2.recognize_video_detect.main]
public static void startLabels(RekognitionClient rekClient, NotificationChannel channel, String bucket, String video) {
try {
S3Object s3Obj = S3Object.builder().bucket(bucket).name(video).build();
Video vidOb = Video.builder().s3Object(s3Obj).build();
StartLabelDetectionRequest labelDetectionRequest = StartLabelDetectionRequest.builder().jobTag("DetectingLabels").notificationChannel(channel).video(vidOb).minConfidence(50F).build();
StartLabelDetectionResponse labelDetectionResponse = rekClient.startLabelDetection(labelDetectionRequest);
startJobId = labelDetectionResponse.jobId();
boolean ans = true;
String status = "";
int yy = 0;
while (ans) {
GetLabelDetectionRequest detectionRequest = GetLabelDetectionRequest.builder().jobId(startJobId).maxResults(10).build();
GetLabelDetectionResponse result = rekClient.getLabelDetection(detectionRequest);
status = result.jobStatusAsString();
if (status.compareTo("SUCCEEDED") == 0)
ans = false;
else
System.out.println(yy + " status is: " + status);
Thread.sleep(1000);
yy++;
}
System.out.println(startJobId + " status is: " + status);
} catch (RekognitionException | InterruptedException e) {
e.getMessage();
System.exit(1);
}
}
use of software.amazon.awssdk.services.rekognition.model.S3Object in project aws-doc-sdk-examples by awsdocs.
the class VideoDetectText method startTextLabels.
// snippet-start:[rekognition.java2.recognize_video_text.main]
public static void startTextLabels(RekognitionClient rekClient, NotificationChannel channel, String bucket, String video) {
try {
S3Object s3Obj = S3Object.builder().bucket(bucket).name(video).build();
Video vidOb = Video.builder().s3Object(s3Obj).build();
StartTextDetectionRequest labelDetectionRequest = StartTextDetectionRequest.builder().jobTag("DetectingLabels").notificationChannel(channel).video(vidOb).build();
StartTextDetectionResponse labelDetectionResponse = rekClient.startTextDetection(labelDetectionRequest);
startJobId = labelDetectionResponse.jobId();
} catch (RekognitionException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.rekognition.model.S3Object in project aws-doc-sdk-examples by awsdocs.
the class DetectLabelsS3 method getLabelsfromImage.
// snippet-start:[rekognition.java2.detect_labels_s3.main]
public static void getLabelsfromImage(RekognitionClient rekClient, String bucket, String image) {
try {
S3Object s3Object = S3Object.builder().bucket(bucket).name(image).build();
Image myImage = Image.builder().s3Object(s3Object).build();
DetectLabelsRequest detectLabelsRequest = DetectLabelsRequest.builder().image(myImage).maxLabels(10).build();
DetectLabelsResponse labelsResponse = rekClient.detectLabels(detectLabelsRequest);
List<Label> labels = labelsResponse.labels();
System.out.println("Detected labels for the given photo");
for (Label label : labels) {
System.out.println(label.name() + ": " + label.confidence().toString());
}
} catch (RekognitionException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.rekognition.model.S3Object 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