# -*- coding: utf-8 -*-
"""
Created on Sat Dec 1 21:28:07 2018
@author: Administrator
"""
from aip import AipOcr
# 定义常量
APP_ID = '10379743'
API_KEY = 'QGGvDG2yYiVFvujo6rlX4SvD'
SECRET_KEY = 'PcEAUvFO0z0TyiCdhwrbG97iVBdyb3Pk'
# 初始化文字识别分类器
aipOcr=AipOcr(APP_ID, API_KEY, SECRET_KEY)
# 读取图片
filePath = "aaatp.png"
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
# 定义参数变量
options = {
'detect_direction': 'true',
'language_type': 'CHN_ENG',
}
# 网络图片文字文字识别接口
result = aipOcr.webImage(get_file_content(filePath),options)
# 如果图片是url 调用示例如下
# result = apiOcr.webImage('http://www.xxxxxx.com/img.jpg')
print(result)
百度ai图片转文字
最新推荐文章于 2023-06-16 13:28:25 发布