Search code examples
apiocrgoogle-vision

Google Vision Text Detection returns too much unnecesary data


When using Google Vision to run text detection on a menu, the response from their API is way too large and returns way too much data that I don't need. I just want the text from the menu, not all the coordinates that come with the response. I can't find anything about narrowing down the response in any documentation i've read. Does someone know how to specify what fields get returned in the response?

Heres my request:

POST: https://vision.googleapis.com/v1/images:annotate?key=<MY_KEY>

BODY:

{
  "requests": [
    {
      "image": {
        "content": "...base64-encoded-image-content..."
      },
      "features": [
        {
          "type": "TEXT_DETECTION"
        }
      ]
    }
  ]
}

Solution

  • I figured it out. I could not find any documentation on how to do this, I had to just guess for like half an hour. If someone knows of any documentation on this let me know.

    Anyway you can use the "fields" parameter to narrow down the response like so:

    POST: https://vision.googleapis.com/v1/images:annotate?key=<MY_KEY>&fields=responses.fullTextAnnotation.text
    

    This will only return the menu text from the Google Vision text detection API