4 Star 41 Fork 14

Gitee 极速下载/chineseocr

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/chineseocr/chineseocr
克隆/下载
post-demo.py 994 Bytes
一键复制 编辑 原始数据 按行查看 历史
# -*- coding: utf-8 -*-
"""
@author: lywen
后台通过接口调用服务,获取OCR识别结果
"""
import base64
import requests
import json
def read_img_base64(p):
with open(p,'rb') as f:
imgString = base64.b64encode(f.read())
imgString=b'data:image/jpeg;base64,'+imgString
return imgString.decode()
def post(p,billModel='通用OCR'):
URL='http://127.0.0.1:8080/ocr'##url地址
imgString = read_img_base64(p)
headers = {}
param = {'billModel':billModel,##目前支持三种 通用OCR/ 火车票/ 身份证/
'imgString':imgString,
'textAngle':True
}
param = json.dumps(param)
if 1:
req = requests.post(URL,data= param,headers=None,timeout=50)
data = req.content.decode('utf-8')
data = json.loads(data)
else:
data =[]
print(data)
if __name__=='__main__':
p = 'test/idcard-demo.jpeg'
post(p,'身份证')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/chineseocr.git
git@gitee.com:mirrors/chineseocr.git
mirrors
chineseocr
chineseocr
app

搜索帮助