By using AWS re:Post, you agree to the Terms of Use

Questions tagged with Amazon Rekognition

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

AWS Rekognition Adding Faces to Collection

I am trying to use the AWS Rekognition Service ( Java SDK ) & adding faces to an existing collection. But I am getting following issue Error :"Request has invalid image format (Service: Rekognition, Status Code: 400, Request ID: 4adc5ed9-3484-420a-bb78-34aebe6d8bbb)" As per the documentation from the below URL for Java, no need to do base64 for images. I am not sure what I am missing here. Can anyone assist here? ************** public class AddFacesToCollection { public static final String collectionId = "vowCollection"; public static final String bucket = "vowvideo"; public static final String photo = "sachin.jpeg"; static LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); static { loggerContext.getLogger("org.apache.http").setLevel(Level.INFO); loggerContext.getLogger("com.amazonaws").setLevel(Level.INFO); } 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); } } } -Snehadeep.
asked a month ago