TrWebOCR Docker#
开源易用的中文离线OCR
Docker#
docker run -itd --rm -p 8089:8089 --name trwebocr mmmz/trwebocr:latest
docker run -d -p 8089:8089 --name trwebocr mmmz/trwebocr
接口调用示例#
Python 使用File上传文件
import requests
url = 'http://192.168.31.108:8089/api/tr-run/'
img1_file = {
'file': open('img1.png', 'rb')
}
res = requests.post(url=url, data={'compress': 0}, files=img1_file)
Python 使用Base64
import requests
import base64
def img_to_base64(img_path):
with open(img_path, 'rb')as read:
b64 = base64.b64encode(read.read())
return b64
url = 'http://192.168.31.108:8089/api/tr-run/'
img_b64 = img_to_base64('./img1.png')
res = requests.post(url=url, data={'img': img_b64})