private static void GetResultsFaceSearchCollection()

in code_examples/java_examples/stored_video/java-rek-video.java [306:362]


    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);

   }