ChineseOCR在線API
界面
- 提供多種接口調用方式,比如在線調用、Javascript api調用、curl api調用和python api調用四種方式,本次使用javascript api調用的方式進行OCR識別

代碼
import glob
import base64
import os
import requests
import threading
import time
from time import ctimeWSI_MASK_PATH = 'E:\\OCRTest'#存放圖片的文件夾路徑
paths = glob.glob(os.path.join(WSI_MASK_PATH, '*.jpg'))
print(paths)
print("******************************************************************")base_url = "https://momodel.cn/pyapi/apps/run/"
app_id = "5cd04ee51afd94639a492b8e"
app_version = "0-2-0"def read_file(filpos,i):with open(filpos+str(i)+".jpg","rb")as f:data = f.read()encoder = base64.b64encode(data)# print(str(encoder,'utf-8'))fill_with_base64_image = str(encoder, 'utf-8')input_dic = {"img": {"val": fill_with_base64_image, "type": "img"}}output_dic = {"take_time": {"type": "float"}, "output": {"type": "str"}}payload = {"app": {"input": input_dic, "output": output_dic}, "version": app_version}response = requests.post(base_url + app_id, json=payload)print(response.json())threads = []
x=0
for t in range(0,3):t= threading.Thread(target=read_file,args=("E:\\OCRTest\\",x))threads.append(t)time.sleep(10)x+=1#join在里面時候只有第一個子進程結束才能打開第二個進程,if__name__ 調用時不可用
if __name__=="__main__":for thr in threads:thr.start()thr.join()print("all over %s"%ctime())
識別結果

問題