源码地址:https://github.com/yicaifenchen8/learning.git
1.初始化AipFace对象
aipOcr = AipOcr(APP_ID, API_KEY, SECRET_KEY)
2.读取图片
filePath = "../res/orc.jpg"
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
file = get_file_content(filePath)
3.调用通用文字识别接口
options = {
'detect_direction': 'false',
'language_type': 'CHN_ENG',
}
result = aipOcr.basicGeneral(file, options)
4.输出结果
print(result)
print(result['words_result'])
# 解决中午转json编码问题
str = json.dumps(result, ensure_ascii=False)
print(str)
源码地址:https://github.com/yicaifenchen8/learning.git