使用python实现对于chineseocr的API调用

ChineseOCR在线API

界面

  • 提供多种接口调用方式,比如在线调用、Javascript api调用、curl api调用和python api调用四种方式,本次使用javascript api调用的方式进行OCR识别

在线Base64 转化工具

代码修改

  • 新增一个变量fill_with_base64_image接收图片的base64编码的字符串
  • 将input内的<fill_with_base64_image>两边的尖括号删除,运行代码
  • 返回两个参数,take_time和output,take_time接收检测的时间,output接收识别后的字符串
import requests

base_url = "https://momodel.cn/pyapi/apps/run/"
app_id = "5cd04ee51afd94639a492b8e"
fill_with_base64_image = ""
input_dic = {"img": {"val": fill_with_base64_image, "type": "img"}}
output_dic = {"take_time": {"type": "float"}, "output": {"type": "str"}}
app_version = "0-2-0"
payload = {"app": {"input": input_dic, "output": output_dic}, "version": app_version}
response = requests.post(base_url + app_id, json=payload)
print(response.json())

检测结果

猜你喜欢

转载自blog.csdn.net/CHYabc123456hh/article/details/106798077
今日推荐