OCR via Web API

Options
System
System Posts: 24 admin
Hi,
I want to send a picture to a API to do the OCR. But after I posted successfully the response told me it doesn't work. The OCR webAPI can't read the body data. The API use the base64 encode for the picture. And when I setup the header to content-type: application/x-www-form-urlencoded,chartset=uft-8, I found in the result the header is still the application/json. How can I configure it?

Thanks,
Xia

Answers

  • Jozef_783863
    Jozef_783863 Posts: 331 admin
    Options

    @XIA_175253 Can you share why you are using an API action for OCR, instead of using the OCR action? If the API is public, can you also share a link to the API documentation? Thank you!

    Images: Optical Character Recognition (OCR)
    https://help.catalytic.com/docs/images-optical-character-recognition-ocr/

  • XIA_175253
    Options

    Hi Jozef,
    We are developing a OCR function for Chinese Invoice verification which include the invoice format and Chinese characters.
    So we use the local API function from BAIDU who is the one of the biggest AI provider in china market.
    Please find the attached document from their portal. And i also attached the link but that's in Chinese.

    HTTP Method:POST
    Request URL: https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic

    URLparam:
    参数 值
    access_token combine the API Key,Secret Key to get the access_token

    Header:
    Param value
    Content-Type application/x-www-form-urlencoded

    Body:
    Params
    Param Must Style
    image string - 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持 jpg/jpeg/png/bmp 格式,当image字段存在时url字段失效

    https://cloud.baidu.com/doc/OCR/s/zk3h7xz52

  • Jozef_783863
    Jozef_783863 Posts: 331 admin
    edited September 2020
    Options

    @XIA_175253 We are currently checking in to address this issue as soon as possible. I will share a new update as soon as this gets addressed. In the meantime, a different body configuration should do something similar. If your body is like foo=url-encoded-bar it should now look like { "foo": "bar"}. Does this body configuration meet your use case as well?

  • XIA_175253
    Options

    Hi Jozef,
    Yes, the body is meet the case. like {"image":img}