Search in sources :

Example 1 with CelebrityRecognition

use of com.amazonaws.services.rekognition.model.CelebrityRecognition in project aws-doc-sdk-examples by awsdocs.

the class VideoDetect method GetResultsCelebrities.

// Gets the results of a celebrity detection analysis by calling GetCelebrityRecognition.
// Celebrity detection is started by calling StartCelebrityRecognition.
private static void GetResultsCelebrities() throws Exception {
    int maxResults = 10;
    String paginationToken = null;
    GetCelebrityRecognitionResult celebrityRecognitionResult = null;
    do {
        if (celebrityRecognitionResult != null) {
            paginationToken = celebrityRecognitionResult.getNextToken();
        }
        celebrityRecognitionResult = rek.getCelebrityRecognition(new GetCelebrityRecognitionRequest().withJobId(startJobId).withNextToken(paginationToken).withSortBy(CelebrityRecognitionSortBy.TIMESTAMP).withMaxResults(maxResults));
        System.out.println("File info for page");
        VideoMetadata videoMetaData = celebrityRecognitionResult.getVideoMetadata();
        System.out.println("Format: " + videoMetaData.getFormat());
        System.out.println("Codec: " + videoMetaData.getCodec());
        System.out.println("Duration: " + videoMetaData.getDurationMillis());
        System.out.println("FrameRate: " + videoMetaData.getFrameRate());
        System.out.println("Job");
        System.out.println("Job status: " + celebrityRecognitionResult.getJobStatus());
        // Show celebrities
        List<CelebrityRecognition> celebs = celebrityRecognitionResult.getCelebrities();
        for (CelebrityRecognition celeb : celebs) {
            long seconds = celeb.getTimestamp() / 1000;
            System.out.print("Sec: " + Long.toString(seconds) + " ");
            CelebrityDetail details = celeb.getCelebrity();
            System.out.println("Name: " + details.getName());
            System.out.println("Id: " + details.getId());
            System.out.println();
        }
    } while (celebrityRecognitionResult != null && celebrityRecognitionResult.getNextToken() != null);
}
Also used : CelebrityRecognition(com.amazonaws.services.rekognition.model.CelebrityRecognition) CelebrityDetail(com.amazonaws.services.rekognition.model.CelebrityDetail) GetCelebrityRecognitionRequest(com.amazonaws.services.rekognition.model.GetCelebrityRecognitionRequest) GetCelebrityRecognitionResult(com.amazonaws.services.rekognition.model.GetCelebrityRecognitionResult) VideoMetadata(com.amazonaws.services.rekognition.model.VideoMetadata)

Aggregations

CelebrityDetail (com.amazonaws.services.rekognition.model.CelebrityDetail)1 CelebrityRecognition (com.amazonaws.services.rekognition.model.CelebrityRecognition)1 GetCelebrityRecognitionRequest (com.amazonaws.services.rekognition.model.GetCelebrityRecognitionRequest)1 GetCelebrityRecognitionResult (com.amazonaws.services.rekognition.model.GetCelebrityRecognitionResult)1 VideoMetadata (com.amazonaws.services.rekognition.model.VideoMetadata)1