2 Star 2 Fork 3

KKDP/spider-code

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
调用百度OCR api接口.py 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
import requests
from aip import AipOcr
# url = 'https://aip.baidubce.com/oauth/2.0/token?'
# grant = 'grant_type=client_credentials&'
# id = 'client_id=XPFfu1PWesIgRou2sMoTIuz5&'
# secret = 'client_secret=1Lq1Uw10sU884hNvN4Vrk2fXjGbSxPvY'
# new_url = url + grant + id + secret
# access_token = requests.post(new_url).json()['access_token']
# print(access_token)
# url = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general?access_token='
# URL = url + access_token
""" 你的 APPID AK SK """
APP_ID = '10777720'
API_KEY = 'XPFfu1PWesIgRou2sMoTIuz5'
SECRET_KEY = '1Lq1Uw10sU884hNvN4Vrk2fXjGbSxPvY'
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('C:/Users/Administrator/Desktop/测试.jpg')
""" 调用通用文字识别(高精度标准版), 图片参数为本地图片 """
content = client.basicAccurate(image)['words_result']
full = ''
for i in content:
full = full + i['words'] + '\n'
print(full)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jjhoc/spider-code.git
git@gitee.com:jjhoc/spider-code.git
jjhoc
spider-code
spider-code
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385