Search in sources :

Example 1 with StartLabelDetectionResponse

use of software.amazon.awssdk.services.rekognition.model.StartLabelDetectionResponse 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);
    }
}
Also used : GetLabelDetectionResponse(software.amazon.awssdk.services.rekognition.model.GetLabelDetectionResponse) RekognitionException(software.amazon.awssdk.services.rekognition.model.RekognitionException) Video(software.amazon.awssdk.services.rekognition.model.Video) GetLabelDetectionRequest(software.amazon.awssdk.services.rekognition.model.GetLabelDetectionRequest) StartLabelDetectionRequest(software.amazon.awssdk.services.rekognition.model.StartLabelDetectionRequest) S3Object(software.amazon.awssdk.services.rekognition.model.S3Object) StartLabelDetectionResponse(software.amazon.awssdk.services.rekognition.model.StartLabelDetectionResponse)

Aggregations

GetLabelDetectionRequest (software.amazon.awssdk.services.rekognition.model.GetLabelDetectionRequest)1 GetLabelDetectionResponse (software.amazon.awssdk.services.rekognition.model.GetLabelDetectionResponse)1 RekognitionException (software.amazon.awssdk.services.rekognition.model.RekognitionException)1 S3Object (software.amazon.awssdk.services.rekognition.model.S3Object)1 StartLabelDetectionRequest (software.amazon.awssdk.services.rekognition.model.StartLabelDetectionRequest)1 StartLabelDetectionResponse (software.amazon.awssdk.services.rekognition.model.StartLabelDetectionResponse)1 Video (software.amazon.awssdk.services.rekognition.model.Video)1