ocr_api_server icon indicating copy to clipboard operation
ocr_api_server copied to clipboard

http://localhost:9898/ocr/b64 用Java请求不成功???

Open laopaoer-wallet opened this issue 3 years ago • 1 comments

可以发一下 CURL 的请求格式?

laopaoer-wallet avatar Jun 14 '22 11:06 laopaoer-wallet

modify method get_img in FILE ocr_server.py

def get_img(request, img_type='file', img_name='image'):
    if img_type == 'b64': #
        try:  # json str of multiple images
            dic = json.loads(request.get_data())
            img_base64 = dic.get(img_name)
            if 'base64,' in img_base64:
                img_base64 = img_base64.split('base64,')[1]
            img = base64.b64decode(img_base64)
        except Exception as e:  # just base64 of single image
            pass
    else:
        img = request.files.get(img_name).read()
    return img

and POST http://127.0.0.1:9898/ocr/b64/json the body is

{
    "image": "data:image/png;base64,iVBxxxxORQrKm"
}

hsmustard avatar Jul 14 '22 03:07 hsmustard