0

I have try to request TEXT_DETECTION and 1 of maxResults, this is body json sample :

{
  "requests": [
    {

      "image": {
          "content": "",
          "source": {
              "gcsImageUri": "",
              "imageUri": "https://www.optumhealthfinancial.com/content/dam/optumhealthfinancial/Images/receipts.gif"
            }
        },
      "features": [
        {
          "type": "TEXT_DETECTION",
          "maxResults": 1
        }
      ]
    }
  ]
}

But the result of textAnnotations has more than one record & more than 1MB size of response.

itx
  • 1,327
  • 1
  • 15
  • 38

2 Answers2

1

From the description of Text detection responses:

A TEXT_DETECTION response includes the detected phrase, its bounding box, and individual words and their bounding boxes

So you'll have bounding boxes for each word in your example image. Besides, from the definition of TextAnnotation

TextAnnotation contains a structured representation of OCR extracted text. The hierarchy of an OCR extracted text structure is like this: TextAnnotation -> Page -> Block -> Paragraph -> Word ->

The size of your results are due the the quantity of information contained in you example image. maxResults is for cases where there can be more than one result (faceAnnotation, textAnnotations) as described here. You are not getting multiple results, there's one result for each word of the detected paragraph.

If you want a smaller result, run the request using DOCUMENT_TEXT_DETECTION:

{
  "requests": 
  [
    {
      "image": 
      {
        "content": "",
        "source": 
        {
          "gcsImageUri": "",
          "imageUri": "https://www.optumhealthfinancial.com/content/dam/optumhealthfinancial/Images/receipts.gif"
        }
      },
      "features": 
      [
        {
          "type": "DOCUMENT_TEXT_DETECTION",
          "maxResults": 1
        }
      ]
    }
  ]
}
Victor M Perez
  • 2,185
  • 3
  • 19
  • 22
  • I mean, what the function of `maxResults` if I still get more than one result of textAnnotation? – itx Jan 16 '18 at 02:59
  • maxResults is for cases where there can be more than one result (faceAnnotation, textAnnotations). Look [here](https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#AnnotateImageResponse). You are not getting multiple results, there's one result for each word of the detected paragraph. If you want a smaller result, run the request the way I show below – Victor M Perez Jan 16 '18 at 16:49
  • Run this, using **DOCUMENT_TEXT_DETECTION**: `{ "requests": [ { "image": { "content": "", "source": { "gcsImageUri": "", "imageUri": "https://www.optumhealthfinancial.com/content/dam/optumhealthfinancial/Images/receipts.gif" } }, "features": [ { "type": "DOCUMENT_TEXT_DETECTION", "maxResults": 1 } ] } ] }` – Victor M Perez Jan 16 '18 at 16:54
0

maxResults doesn't apply to TEXT_DETECTION

Maximum number of results of this type. Does not apply to TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS.

Brendan
  • 1,017
  • 5
  • 7