Search in sources :

Example 1 with PersonDetection

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

the class VideoDetect method GetResultsPersons.

// Gets person tracking information using the GetPersonTracking operation. Person tracking
// is started by calling StartPersonTracking
private static void GetResultsPersons() throws Exception {
    int maxResults = 10;
    String paginationToken = null;
    GetPersonTrackingResult personTrackingResult = null;
    do {
        if (personTrackingResult != null) {
            paginationToken = personTrackingResult.getNextToken();
        }
        personTrackingResult = rek.getPersonTracking(new GetPersonTrackingRequest().withJobId(startJobId).withNextToken(paginationToken).withSortBy(PersonTrackingSortBy.TIMESTAMP).withMaxResults(maxResults));
        VideoMetadata videoMetaData = personTrackingResult.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());
        // Show persons, confidence and detection times
        List<PersonDetection> detectedPersons = personTrackingResult.getPersons();
        for (PersonDetection detectedPerson : detectedPersons) {
            long seconds = detectedPerson.getTimestamp() / 1000;
            System.out.print("Sec: " + Long.toString(seconds) + " ");
            System.out.println("Person Identifier: " + detectedPerson.getPerson().getIndex());
            System.out.println();
        }
    } while (personTrackingResult != null && personTrackingResult.getNextToken() != null);
}
Also used : GetPersonTrackingRequest(com.amazonaws.services.rekognition.model.GetPersonTrackingRequest) PersonDetection(com.amazonaws.services.rekognition.model.PersonDetection) GetPersonTrackingResult(com.amazonaws.services.rekognition.model.GetPersonTrackingResult) VideoMetadata(com.amazonaws.services.rekognition.model.VideoMetadata)

Aggregations

GetPersonTrackingRequest (com.amazonaws.services.rekognition.model.GetPersonTrackingRequest)1 GetPersonTrackingResult (com.amazonaws.services.rekognition.model.GetPersonTrackingResult)1 PersonDetection (com.amazonaws.services.rekognition.model.PersonDetection)1 VideoMetadata (com.amazonaws.services.rekognition.model.VideoMetadata)1