Search in sources :

Example 1 with VideoMetadata

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

Example 2 with VideoMetadata

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);
}
Also used : GetPersonTrackingRequest(com.amazonaws.services.rekognition.model.GetPersonTrackingRequest) PersonDetection(com.amazonaws.services.rekognition.model.PersonDetection) GetPersonTrackingResult(com.amazonaws.services.rekognition.model.GetPersonTrackingResult) VideoMetadata(com.amazonaws.services.rekognition.model.VideoMetadata)

Example 3 with VideoMetadata

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);
}
Also used : CelebrityRecognition(com.amazonaws.services.rekognition.model.CelebrityRecognition) CelebrityDetail(com.amazonaws.services.rekognition.model.CelebrityDetail) GetCelebrityRecognitionRequest(com.amazonaws.services.rekognition.model.GetCelebrityRecognitionRequest) GetCelebrityRecognitionResult(com.amazonaws.services.rekognition.model.GetCelebrityRecognitionResult) VideoMetadata(com.amazonaws.services.rekognition.model.VideoMetadata)

Example 4 with VideoMetadata

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);
}
Also used : GetContentModerationResult(com.amazonaws.services.rekognition.model.GetContentModerationResult) GetContentModerationRequest(com.amazonaws.services.rekognition.model.GetContentModerationRequest) ContentModerationDetection(com.amazonaws.services.rekognition.model.ContentModerationDetection) VideoMetadata(com.amazonaws.services.rekognition.model.VideoMetadata)

Example 5 with VideoMetadata

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);
}
Also used : GetLabelDetectionRequest(com.amazonaws.services.rekognition.model.GetLabelDetectionRequest) AmazonRekognition(com.amazonaws.services.rekognition.AmazonRekognition) GetLabelDetectionResult(com.amazonaws.services.rekognition.model.GetLabelDetectionResult) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger) VideoMetadata(com.amazonaws.services.rekognition.model.VideoMetadata) LabelDetection(com.amazonaws.services.rekognition.model.LabelDetection)

Aggregations

VideoMetadata (com.amazonaws.services.rekognition.model.VideoMetadata)7 GetLabelDetectionRequest (com.amazonaws.services.rekognition.model.GetLabelDetectionRequest)2 GetLabelDetectionResult (com.amazonaws.services.rekognition.model.GetLabelDetectionResult)2 LabelDetection (com.amazonaws.services.rekognition.model.LabelDetection)2 LambdaLogger (com.amazonaws.services.lambda.runtime.LambdaLogger)1 AmazonRekognition (com.amazonaws.services.rekognition.AmazonRekognition)1 CelebrityDetail (com.amazonaws.services.rekognition.model.CelebrityDetail)1 CelebrityRecognition (com.amazonaws.services.rekognition.model.CelebrityRecognition)1 ContentModerationDetection (com.amazonaws.services.rekognition.model.ContentModerationDetection)1 Face (com.amazonaws.services.rekognition.model.Face)1 FaceDetection (com.amazonaws.services.rekognition.model.FaceDetection)1 FaceMatch (com.amazonaws.services.rekognition.model.FaceMatch)1 GetCelebrityRecognitionRequest (com.amazonaws.services.rekognition.model.GetCelebrityRecognitionRequest)1 GetCelebrityRecognitionResult (com.amazonaws.services.rekognition.model.GetCelebrityRecognitionResult)1 GetContentModerationRequest (com.amazonaws.services.rekognition.model.GetContentModerationRequest)1 GetContentModerationResult (com.amazonaws.services.rekognition.model.GetContentModerationResult)1 GetFaceDetectionRequest (com.amazonaws.services.rekognition.model.GetFaceDetectionRequest)1 GetFaceDetectionResult (com.amazonaws.services.rekognition.model.GetFaceDetectionResult)1 GetFaceSearchRequest (com.amazonaws.services.rekognition.model.GetFaceSearchRequest)1 GetFaceSearchResult (com.amazonaws.services.rekognition.model.GetFaceSearchResult)1