use of software.amazon.awssdk.services.rekognition.model.RekognitionException in project aws-doc-sdk-examples by awsdocs.
the class VideoDetectInappropriate method GetModResults.
public static void GetModResults(RekognitionClient rekClient) {
try {
String paginationToken = null;
GetContentModerationResponse modDetectionResponse = null;
Boolean finished = false;
String status = "";
int yy = 0;
do {
if (modDetectionResponse != null)
paginationToken = modDetectionResponse.nextToken();
GetContentModerationRequest modRequest = GetContentModerationRequest.builder().jobId(startJobId).nextToken(paginationToken).maxResults(10).build();
// Wait until the job succeeds
while (!finished) {
modDetectionResponse = rekClient.getContentModeration(modRequest);
status = modDetectionResponse.jobStatusAsString();
if (status.compareTo("SUCCEEDED") == 0)
finished = true;
else {
System.out.println(yy + " status is: " + status);
Thread.sleep(1000);
}
yy++;
}
finished = false;
// Proceed when the job is done - otherwise VideoMetadata is null
VideoMetadata videoMetaData = modDetectionResponse.videoMetadata();
System.out.println("Format: " + videoMetaData.format());
System.out.println("Codec: " + videoMetaData.codec());
System.out.println("Duration: " + videoMetaData.durationMillis());
System.out.println("FrameRate: " + videoMetaData.frameRate());
System.out.println("Job");
List<ContentModerationDetection> mods = modDetectionResponse.moderationLabels();
for (ContentModerationDetection mod : mods) {
long seconds = mod.timestamp() / 1000;
System.out.print("Mod label: " + seconds + " ");
System.out.println(mod.moderationLabel().toString());
System.out.println();
}
} while (modDetectionResponse != null && modDetectionResponse.nextToken() != null);
} catch (RekognitionException | InterruptedException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.rekognition.model.RekognitionException in project aws-doc-sdk-examples by awsdocs.
the class VideoDetectText method GetTextResults.
public static void GetTextResults(RekognitionClient rekClient) {
try {
String paginationToken = null;
GetTextDetectionResponse textDetectionResponse = null;
Boolean finished = false;
String status = "";
int yy = 0;
do {
if (textDetectionResponse != null)
paginationToken = textDetectionResponse.nextToken();
GetTextDetectionRequest recognitionRequest = GetTextDetectionRequest.builder().jobId(startJobId).nextToken(paginationToken).maxResults(10).build();
// Wait until the job succeeds
while (!finished) {
textDetectionResponse = rekClient.getTextDetection(recognitionRequest);
status = textDetectionResponse.jobStatusAsString();
if (status.compareTo("SUCCEEDED") == 0)
finished = true;
else {
System.out.println(yy + " status is: " + status);
Thread.sleep(1000);
}
yy++;
}
finished = false;
// Proceed when the job is done - otherwise VideoMetadata is null
VideoMetadata videoMetaData = textDetectionResponse.videoMetadata();
System.out.println("Format: " + videoMetaData.format());
System.out.println("Codec: " + videoMetaData.codec());
System.out.println("Duration: " + videoMetaData.durationMillis());
System.out.println("FrameRate: " + videoMetaData.frameRate());
System.out.println("Job");
List<TextDetectionResult> labels = textDetectionResponse.textDetections();
for (TextDetectionResult detectedText : labels) {
System.out.println("Confidence: " + detectedText.textDetection().confidence().toString());
System.out.println("Id : " + detectedText.textDetection().id());
System.out.println("Parent Id: " + detectedText.textDetection().parentId());
System.out.println("Type: " + detectedText.textDetection().type());
System.out.println("Text: " + detectedText.textDetection().detectedText());
System.out.println();
}
} while (textDetectionResponse != null && textDetectionResponse.nextToken() != null);
} catch (RekognitionException | InterruptedException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.rekognition.model.RekognitionException in project aws-doc-sdk-examples by awsdocs.
the class DescribeCollection method describeColl.
// snippet-start:[rekognition.java2.describe_collection.main]
public static void describeColl(RekognitionClient rekClient, String collectionName) {
try {
DescribeCollectionRequest describeCollectionRequest = DescribeCollectionRequest.builder().collectionId(collectionName).build();
DescribeCollectionResponse describeCollectionResponse = rekClient.describeCollection(describeCollectionRequest);
System.out.println("Collection Arn : " + describeCollectionResponse.collectionARN());
System.out.println("Created : " + describeCollectionResponse.creationTimestamp().toString());
} catch (RekognitionException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.rekognition.model.RekognitionException in project aws-doc-sdk-examples by awsdocs.
the class VideoPersonDetection method GetPersonDetectionResults.
public static void GetPersonDetectionResults(RekognitionClient rekClient) {
try {
String paginationToken = null;
GetPersonTrackingResponse personTrackingResult = null;
Boolean finished = false;
String status = "";
int yy = 0;
do {
if (personTrackingResult != null)
paginationToken = personTrackingResult.nextToken();
GetPersonTrackingRequest recognitionRequest = GetPersonTrackingRequest.builder().jobId(startJobId).nextToken(paginationToken).maxResults(10).build();
// Wait until the job succeeds
while (!finished) {
personTrackingResult = rekClient.getPersonTracking(recognitionRequest);
status = personTrackingResult.jobStatusAsString();
if (status.compareTo("SUCCEEDED") == 0)
finished = true;
else {
System.out.println(yy + " status is: " + status);
Thread.sleep(1000);
}
yy++;
}
finished = false;
// Proceed when the job is done - otherwise VideoMetadata is null
VideoMetadata videoMetaData = personTrackingResult.videoMetadata();
System.out.println("Format: " + videoMetaData.format());
System.out.println("Codec: " + videoMetaData.codec());
System.out.println("Duration: " + videoMetaData.durationMillis());
System.out.println("FrameRate: " + videoMetaData.frameRate());
System.out.println("Job");
List<PersonDetection> detectedPersons = personTrackingResult.persons();
for (PersonDetection detectedPerson : detectedPersons) {
long seconds = detectedPerson.timestamp() / 1000;
System.out.print("Sec: " + seconds + " ");
System.out.println("Person Identifier: " + detectedPerson.person().index());
System.out.println();
}
} while (personTrackingResult != null && personTrackingResult.nextToken() != null);
} catch (RekognitionException | InterruptedException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.rekognition.model.RekognitionException in project aws-doc-sdk-examples by awsdocs.
the class VideoPersonDetection method startPersonLabels.
// snippet-start:[rekognition.java2.recognize_video_person.main]
public static void startPersonLabels(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();
StartPersonTrackingRequest personTrackingRequest = StartPersonTrackingRequest.builder().jobTag("DetectingLabels").video(vidOb).notificationChannel(channel).build();
StartPersonTrackingResponse labelDetectionResponse = rekClient.startPersonTracking(personTrackingRequest);
startJobId = labelDetectionResponse.jobId();
} catch (RekognitionException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
Aggregations