AWS Rekognition Adding Faces to Collection

0

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.

https://docs.aws.amazon.com/rekognition/latest/dg/images-information.html

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.

gefragt vor 2 Jahren588 Aufrufe
1 Antwort
0

Hi InvalidImageFormatException usually means and issue with the image format/encoding please take a look at https://docs.aws.amazon.com/rekognition/latest/dg/error-handling.html for details.

AWS
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen