Reputation: 305
we used code in "How to combine multiple PNGs into one big PNG file? " from stackoverflow to append image after image and then send the final image to google's cloud vision api.
Faces are detected properly if we append 165 images and send the final image.
BUT NO faces are detected if we append 170 images and send the final image to the cloud vision api.
NOTE: file size is way under 4 MB limit. Please find attachment for reference
Request for info
we use google's CLOUD VISION API
public List<FaceAnnotation> detectFaces(Path path, int maxResults) throws IOException {
byte[] data = Files.readAllBytes(path);
AnnotateImageRequest request = new AnnotateImageRequest()
.setImage(new Image().encodeContent(data))
.setFeatures(ImmutableList.of(new Feature().setType("FACE_DETECTION").setMaxResults(maxResults)));
Vision.Images.Annotate annotate = vision.images()
.annotate(new BatchAnnotateImagesRequest().setRequests(ImmutableList.of(request)));
// Due to a bug: requests to Vision API containing large images fail
// when GZipped.
annotate.setDisableGZipContent(true);
BatchAnnotateImagesResponse batchResponse = annotate.execute();
assert batchResponse.getResponses().size() == 1;
AnnotateImageResponse response = batchResponse.getResponses().get(0);
if (response.getFaceAnnotations() == null) {
throw new IOException(response.getError() != null ? response.getError().getMessage()
: "Unknown error getting image annotations");
}
System.out.println(response.toPrettyString());
return response.getFaceAnnotations();
}
The error provided is : Here the line 263 is "throw new IOException"
Exception in thread "main" java.io.IOException: image-annotator::error(12): Image processing error!
at conf.FaceDetectApp.detectFaces(FaceDetectApp.java:263)
at conf.FaceDetectApp.main(FaceDetectApp.java:161)
Upvotes: 2
Views: 94