调用百度AI进行图片文字识别(Python)

import os
from aip import AipOcr                 #pip install baidu-aip

""" 你的 APPID AK SK   百度AI创建应用获取 """
APP_ID = '************'
API_KEY =  '************'
SECRET_KEY = '************'

client = AipOcr(APP_ID, API_KEY, SECRET_KEY)

with open('F:/python/photo.png', 'rb') as fp:
    photo=fp.read()
    photo_recognition=client.basicAccurate(photo)#高精度版
    result=photo_recognition['words_result']
    for i in result:
         print(i['words'])

更多见百度SDK开发文档

猜你喜欢

转载自www.cnblogs.com/liubingzhe/p/11317169.html