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