标签:调用 lang imp 秘钥 option 安装百度 zed abi 本地图片
from aip import AipOcr
""" 你的 APPID AK SK """
APP_ID = ‘17746415‘
API_KEY = ‘eFCKvYoFi6g5nLirGH7zedYG‘
SECRET_KEY = ‘9kigA0Sy9oaCjs0OBaHyXbkpzyXQngIz‘
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
""" 读取图片 """
""" 读取图片 """
def get_file_content(filePath):
with open(filePath, ‘rb‘) as fp:
return fp.read()
image = get_file_content(‘2.jpg‘)
""" 如果有可选参数 """
options = {}
options["language_type"] = "CHN_ENG"
options["detect_direction"] = "false"
options["detect_language"] = "false"
options["probability"] = "false"
""" 带参数调用通用文字识别, 图片参数为本地图片 """
res = client.basicGeneral(image, options)
word_lists = res["words_result"]
for i in word_lists:
print(i["words"])
with open("check.txt","a") as f:
f.write(i["words"]+"\n")
文字识别(需要先安装百度的环境),申请百度的秘钥,识别后会写到txt文档中
标签:调用 lang imp 秘钥 option 安装百度 zed abi 本地图片
原文地址:https://www.cnblogs.com/lurj/p/12807525.html