Search code examples
jsonapigoogle-vision

Google Vision Text detection API give a different result compared to their demo page


I want to use their OCR function with Google Vision but like a lot of people here, my result are not the same when I use their HTTP API and their demo page, on their demo page they show the json request and result.

I used the same json request and I have a different result, their demo page is more accurate than their API.

Their demo page : https://cloud.google.com/vision/docs/drag-and-drop

Their API URL : https://vision.googleapis.com/v1/images:annotate?key=YOURAPIKEY You can pass their json generated on their demo to test

The only difference is I use imageUri to send my file and google use their local storage (content param)

With their HTTP API I can catch only the first line but not the second but their demo catch both of them.

Any clue ?

My test image : http://maxence.me/labs/others/c668d1346a74873b8773d7ca19d7feaf_1589063679_0_18.png

My JSON :

requests": [
        {
          "features": [
            {
              "maxResults": 50,
              "type": "LANDMARK_DETECTION"
            },
            {
              "maxResults": 50,
              "type": "FACE_DETECTION"
            },
            {
              "maxResults": 50,
              "type": "OBJECT_LOCALIZATION"
            },
            {
              "maxResults": 50,
              "type": "LOGO_DETECTION"
            },
            {
              "maxResults": 50,
              "type": "LABEL_DETECTION"
            },
            {
              "maxResults": 50,
              "type": "DOCUMENT_TEXT_DETECTION"
            },
            {
              "maxResults": 50,
              "type": "SAFE_SEARCH_DETECTION"
            },
            {
              "maxResults": 50,
              "type": "IMAGE_PROPERTIES"
            },
            {
              "maxResults": 50,
              "type": "CROP_HINTS"
            }
          ],
          "image": {
            "source": {
                "imageUri": "http://maxence.me/labs/others/c668d1346a74873b8773d7ca19d7feaf_1589063679_0_18.png"
            }
          },
          "imageContext": {
            "cropHintsParams": {
              "aspectRatios": [
                0.8,
                1,
                1.2
              ]
            }
          }
        }
      ]
    }

My result : https://pastebin.com/fsWPKg1r

Google Vision Demo JSON :

{
  "requests": [
    {
      "features": [
        {
          "maxResults": 50,
          "type": "LANDMARK_DETECTION"
        },
        {
          "maxResults": 50,
          "type": "FACE_DETECTION"
        },
        {
          "maxResults": 50,
          "type": "OBJECT_LOCALIZATION"
        },
        {
          "maxResults": 50,
          "type": "LOGO_DETECTION"
        },
        {
          "maxResults": 50,
          "type": "LABEL_DETECTION"
        },
        {
          "maxResults": 50,
          "type": "DOCUMENT_TEXT_DETECTION"
        },
        {
          "maxResults": 50,
          "type": "SAFE_SEARCH_DETECTION"
        },
        {
          "maxResults": 50,
          "type": "IMAGE_PROPERTIES"
        },
        {
          "maxResults": 50,
          "type": "CROP_HINTS"
        }
      ],
      "image": {
        "content": "(data from c668d1346a74873b8773d7ca19d7feaf_1589063679_0_18.png)"
      },
      "imageContext": {
        "cropHintsParams": {
          "aspectRatios": [
            0.8,
            1,
            1.2
          ]
        }
      }
    }
  ]
}

Google Vision Demo Page result : https://pastebin.com/6ihvKwZr


Solution

  • There was an upgrade on the 15.5.2020

    release notes