Search in sources :

Example 1 with FaceRecord

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

the class AddFacesToCollection method main.

public static void main(String[] args) throws Exception {
    AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient();
    Image image = new Image().withS3Object(new S3Object().withBucket(bucket).withName(photo));
    IndexFacesRequest indexFacesRequest = new IndexFacesRequest().withImage(image).withQualityFilter(QualityFilter.AUTO).withMaxFaces(1).withCollectionId(collectionId).withExternalImageId(photo).withDetectionAttributes("DEFAULT");
    IndexFacesResult indexFacesResult = rekognitionClient.indexFaces(indexFacesRequest);
    System.out.println("Results for " + photo);
    System.out.println("Faces indexed:");
    List<FaceRecord> faceRecords = indexFacesResult.getFaceRecords();
    for (FaceRecord faceRecord : faceRecords) {
        System.out.println("  Face ID: " + faceRecord.getFace().getFaceId());
        System.out.println("  Location:" + faceRecord.getFaceDetail().getBoundingBox().toString());
    }
    List<UnindexedFace> unindexedFaces = indexFacesResult.getUnindexedFaces();
    System.out.println("Faces not indexed:");
    for (UnindexedFace unindexedFace : unindexedFaces) {
        System.out.println("  Location:" + unindexedFace.getFaceDetail().getBoundingBox().toString());
        System.out.println("  Reasons:");
        for (String reason : unindexedFace.getReasons()) {
            System.out.println("   " + reason);
        }
    }
}
Also used : IndexFacesResult(com.amazonaws.services.rekognition.model.IndexFacesResult) IndexFacesRequest(com.amazonaws.services.rekognition.model.IndexFacesRequest) FaceRecord(com.amazonaws.services.rekognition.model.FaceRecord) AmazonRekognition(com.amazonaws.services.rekognition.AmazonRekognition) S3Object(com.amazonaws.services.rekognition.model.S3Object) Image(com.amazonaws.services.rekognition.model.Image) UnindexedFace(com.amazonaws.services.rekognition.model.UnindexedFace)

Aggregations

AmazonRekognition (com.amazonaws.services.rekognition.AmazonRekognition)1 FaceRecord (com.amazonaws.services.rekognition.model.FaceRecord)1 Image (com.amazonaws.services.rekognition.model.Image)1 IndexFacesRequest (com.amazonaws.services.rekognition.model.IndexFacesRequest)1 IndexFacesResult (com.amazonaws.services.rekognition.model.IndexFacesResult)1 S3Object (com.amazonaws.services.rekognition.model.S3Object)1 UnindexedFace (com.amazonaws.services.rekognition.model.UnindexedFace)1