2
votes

In my Java project I'm using Google Cloud Vision API to extract text from images. For text extraction I'm using the following piece of code.

Today, I've found that Google has changed the limits for maximum file size. Previously it was 4 MB.

Now, based on Quotas and Limits and Supported Images, the maximum image file size should be 20 MB for images hosted on Cloud Storage or at a publicly-accessible URL. Also there is maximum JSON request object size (10 MB).

I'm using option with images hosted on Cloud Storage. For images larger than ~7.95 MB (12000 x 6500) I'm getting an error message:

responses {
  error {
    code: 3
    message: "Invalid image contents: gs://... ."
  }
}

For images with lower size I'm getting correct response. I know that there is a recommended size 1024 x 768 for TEXT_DETECTION and DOCUMENT_TEXT_DETECTION feature but, according to the following note, higher size should not be problem:

Note: generally, the Vision API requires images to be a sufficient size so that important features within the request can be easily distinguished. Sizes smaller or larger than these recommended sizes may work. However, smaller sizes may result in lower accuracy, while larger sizes may increase processing time and bandwidth usage without providing comparable benefits in accuracy.

Is there something I did not notice?

Note: I'm getting the same error when calling the Vision API directly (see Bearer tokens section).

2
what are the additional features you are providing to your request JSON .e.g. {."features": [ { "type": "FACE_DETECTION", "maxResults": 1000 } ] }this_is_om_vm
POST vision.googleapis.com/v1/images:annotate { "requests":[ { "image":{ "source":{ "imageUri": "gs://..." } }, "features":[ { "type":"DOCUMENT_TEXT_DETECTION", "maxResults":1 } ] } ] }Milan Hlinák

2 Answers

2
votes

Google has the undocumented limit on image pixels of 75M. The 12000 x 6500 image happens to be over this limit.

0
votes

According to the official documentation : https://cloud.google.com/vision/docs/supported-files?hl=th

File size

Image files sent to the Cloud Vision API should not exceed 20MB. Reducing your file size can significantly improve throughput; however, be careful not to reduce image quality in the process. Note that the Vision API imposes a 10MB JSON request size limit; larger files should be hosted on Cloud Storage or on the web, rather than being passed as base64-encoded content in the JSON itself.