Search in sources :

Example 1 with GetFaceSearchResult

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

the class VideoDetect method GetResultsFaceSearchCollection.

// Gets the results of a collection face search by calling GetFaceSearch.
// The search is started by calling StartFaceSearch.
// ==================================================================
private static void GetResultsFaceSearchCollection() throws Exception {
    GetFaceSearchResult faceSearchResult = null;
    int maxResults = 10;
    String paginationToken = null;
    do {
        if (faceSearchResult != null) {
            paginationToken = faceSearchResult.getNextToken();
        }
        faceSearchResult = rek.getFaceSearch(new GetFaceSearchRequest().withJobId(startJobId).withMaxResults(maxResults).withNextToken(paginationToken).withSortBy(FaceSearchSortBy.TIMESTAMP));
        VideoMetadata videoMetaData = faceSearchResult.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();
        // Show search results
        List<PersonMatch> matches = faceSearchResult.getPersons();
        for (PersonMatch match : matches) {
            long milliSeconds = match.getTimestamp();
            System.out.print("Timestamp: " + Long.toString(milliSeconds));
            System.out.println(" Person number: " + match.getPerson().getIndex());
            List<FaceMatch> faceMatches = match.getFaceMatches();
            if (faceMatches != null) {
                System.out.println("Matches in collection...");
                for (FaceMatch faceMatch : faceMatches) {
                    Face face = faceMatch.getFace();
                    System.out.println("Face Id: " + face.getFaceId());
                    System.out.println("Similarity: " + faceMatch.getSimilarity().toString());
                    System.out.println();
                }
            }
            System.out.println();
        }
        System.out.println();
    } while (faceSearchResult != null && faceSearchResult.getNextToken() != null);
}
Also used : PersonMatch(com.amazonaws.services.rekognition.model.PersonMatch) GetFaceSearchRequest(com.amazonaws.services.rekognition.model.GetFaceSearchRequest) GetFaceSearchResult(com.amazonaws.services.rekognition.model.GetFaceSearchResult) Face(com.amazonaws.services.rekognition.model.Face) FaceMatch(com.amazonaws.services.rekognition.model.FaceMatch) VideoMetadata(com.amazonaws.services.rekognition.model.VideoMetadata)

Aggregations

Face (com.amazonaws.services.rekognition.model.Face)1 FaceMatch (com.amazonaws.services.rekognition.model.FaceMatch)1 GetFaceSearchRequest (com.amazonaws.services.rekognition.model.GetFaceSearchRequest)1 GetFaceSearchResult (com.amazonaws.services.rekognition.model.GetFaceSearchResult)1 PersonMatch (com.amazonaws.services.rekognition.model.PersonMatch)1 VideoMetadata (com.amazonaws.services.rekognition.model.VideoMetadata)1