Search in sources :

Example 1 with GetFaceDetectionResult

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

the class VideoDetect method GetResultsFaces.

// Gets the results of face detection by calling GetFaceDetection. Face
// detection is started by calling StartFaceDetection.
private static void GetResultsFaces() throws Exception {
    int maxResults = 10;
    String paginationToken = null;
    GetFaceDetectionResult faceDetectionResult = null;
    do {
        if (faceDetectionResult != null) {
            paginationToken = faceDetectionResult.getNextToken();
        }
        faceDetectionResult = rek.getFaceDetection(new GetFaceDetectionRequest().withJobId(startJobId).withNextToken(paginationToken).withMaxResults(maxResults));
        VideoMetadata videoMetaData = faceDetectionResult.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 faces, confidence and detection times
        List<FaceDetection> faces = faceDetectionResult.getFaces();
        for (FaceDetection face : faces) {
            long seconds = face.getTimestamp() / 1000;
            System.out.print("Sec: " + Long.toString(seconds) + " ");
            System.out.println(face.getFace().toString());
            System.out.println();
        }
    } while (faceDetectionResult != null && faceDetectionResult.getNextToken() != null);
}
Also used : FaceDetection(com.amazonaws.services.rekognition.model.FaceDetection) GetFaceDetectionResult(com.amazonaws.services.rekognition.model.GetFaceDetectionResult) GetFaceDetectionRequest(com.amazonaws.services.rekognition.model.GetFaceDetectionRequest) VideoMetadata(com.amazonaws.services.rekognition.model.VideoMetadata)

Aggregations

FaceDetection (com.amazonaws.services.rekognition.model.FaceDetection)1 GetFaceDetectionRequest (com.amazonaws.services.rekognition.model.GetFaceDetectionRequest)1 GetFaceDetectionResult (com.amazonaws.services.rekognition.model.GetFaceDetectionResult)1 VideoMetadata (com.amazonaws.services.rekognition.model.VideoMetadata)1