chineseocr_lite
chineseocr_lite copied to clipboard
Python 有接口版吗?
python demo是网页版的, 有没有封装成模块的? 能够直接通过输入图片对象使用的? 然后返回一个json
你可以在网页请求识别之前打开浏览器f12查看项目所请求的连接,比如这个项目,默认好像是http://ip:8089/api/tr-run/ ,你可以在python中用request去请求,会返回一个json。
我也需要这个。可是现在这个接口是multipart/form-data这种提交方式。我搞不定
def ocr(path): headers = { 'accept': 'application/json', # requests won't add a boundary if this header is set when you pass files= # 'Content-Type': 'multipart/form-data', }
files = {
'file': open(path, 'rb'),
}
ip = '192.168.2.156'
port = '8089'
url = "http://" + ip + ":" + port + '/api/tr-run/'
response = requests.post(url, headers=headers, files=files)
return response.json()