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