use of com.amazonaws.services.rekognition.model.VideoMetadata 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);
}
use of com.amazonaws.services.rekognition.model.VideoMetadata 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);
}
use of com.amazonaws.services.rekognition.model.VideoMetadata in project aws-doc-sdk-examples by awsdocs.
the class VideoDetect method GetResultsCelebrities.
// Gets the results of a celebrity detection analysis by calling GetCelebrityRecognition.
// Celebrity detection is started by calling StartCelebrityRecognition.
private static void GetResultsCelebrities() throws Exception {
int maxResults = 10;
String paginationToken = null;
GetCelebrityRecognitionResult celebrityRecognitionResult = null;
do {
if (celebrityRecognitionResult != null) {
paginationToken = celebrityRecognitionResult.getNextToken();
}
celebrityRecognitionResult = rek.getCelebrityRecognition(new GetCelebrityRecognitionRequest().withJobId(startJobId).withNextToken(paginationToken).withSortBy(CelebrityRecognitionSortBy.TIMESTAMP).withMaxResults(maxResults));
System.out.println("File info for page");
VideoMetadata videoMetaData = celebrityRecognitionResult.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("Job");
System.out.println("Job status: " + celebrityRecognitionResult.getJobStatus());
// Show celebrities
List<CelebrityRecognition> celebs = celebrityRecognitionResult.getCelebrities();
for (CelebrityRecognition celeb : celebs) {
long seconds = celeb.getTimestamp() / 1000;
System.out.print("Sec: " + Long.toString(seconds) + " ");
CelebrityDetail details = celeb.getCelebrity();
System.out.println("Name: " + details.getName());
System.out.println("Id: " + details.getId());
System.out.println();
}
} while (celebrityRecognitionResult != null && celebrityRecognitionResult.getNextToken() != null);
}
use of com.amazonaws.services.rekognition.model.VideoMetadata in project aws-doc-sdk-examples by awsdocs.
the class VideoDetect method GetResultsModerationLabels.
// Gets the results of unsafe content label detection by calling
// GetContentModeration. Analysis is started by a call to StartContentModeration.
private static void GetResultsModerationLabels() throws Exception {
int maxResults = 10;
String paginationToken = null;
GetContentModerationResult moderationLabelDetectionResult = null;
do {
if (moderationLabelDetectionResult != null) {
paginationToken = moderationLabelDetectionResult.getNextToken();
}
moderationLabelDetectionResult = rek.getContentModeration(new GetContentModerationRequest().withJobId(startJobId).withNextToken(paginationToken).withSortBy(ContentModerationSortBy.TIMESTAMP).withMaxResults(maxResults));
VideoMetadata videoMetaData = moderationLabelDetectionResult.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 moderated content labels, confidence and detection times
List<ContentModerationDetection> moderationLabelsInFrames = moderationLabelDetectionResult.getModerationLabels();
for (ContentModerationDetection label : moderationLabelsInFrames) {
long seconds = label.getTimestamp() / 1000;
System.out.print("Sec: " + Long.toString(seconds));
System.out.println(label.getModerationLabel().toString());
System.out.println();
}
} while (moderationLabelDetectionResult != null && moderationLabelDetectionResult.getNextToken() != null);
}
use of com.amazonaws.services.rekognition.model.VideoMetadata in project aws-doc-sdk-examples by awsdocs.
the class JobCompletionHandler method GetResultsLabels.
void GetResultsLabels(String startJobId, Context context) throws Exception {
LambdaLogger logger = context.getLogger();
AmazonRekognition rek = AmazonRekognitionClientBuilder.standard().withRegion(Regions.US_EAST_1).build();
int maxResults = 1000;
String paginationToken = null;
GetLabelDetectionResult labelDetectionResult = null;
String labels = "";
Integer labelsCount = 0;
String label = "";
String currentLabel = "";
// Get label detection results and log them.
do {
GetLabelDetectionRequest labelDetectionRequest = new GetLabelDetectionRequest().withJobId(startJobId).withSortBy(LabelDetectionSortBy.NAME).withMaxResults(maxResults).withNextToken(paginationToken);
labelDetectionResult = rek.getLabelDetection(labelDetectionRequest);
paginationToken = labelDetectionResult.getNextToken();
VideoMetadata videoMetaData = labelDetectionResult.getVideoMetadata();
// Add labels to log
List<LabelDetection> detectedLabels = labelDetectionResult.getLabels();
for (LabelDetection detectedLabel : detectedLabels) {
label = detectedLabel.getLabel().getName();
if (label.equals(currentLabel)) {
continue;
}
labels = labels + label + " / ";
currentLabel = label;
labelsCount++;
}
} while (labelDetectionResult != null && labelDetectionResult.getNextToken() != null);
logger.log("Total number of labels : " + labelsCount);
logger.log("labels : " + labels);
}
Aggregations