use of com.amazonaws.services.rekognition.model.PersonMatch 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);
}
Aggregations