打开anaconda prompt 然后执行

pip install baidu-aip
from aip import AipOcr

#下面3个变量请自行更改
APP_ID = '11111111'
API_KEY = '11111111111111'
SECRET_KEY = '11111111111111111111111111111'

aipOcr  = AipOcr(APP_ID, API_KEY, SECRET_KEY)

# 读取图片
filePath = "d:/temp/0001.jpg"
def get_file_content(filePath):
    with open(filePath, 'rb') as fp:
        return fp.read()

# 定义参数变量
options = {
  'detect_direction': 'true',
  'language_type': 'CHN_ENG',
}

# 调用通用文字识别接口
result = aipOcr.accurate(get_file_content(filePath), options)

print(result)

发表评论