from aip import AipOcr
APP_ID = ''
API_KEY = ''
SECRET_KEY = ''
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('文件路徑')
'''可選參數'''
options = {}
options["language_type"] = "CHN_ENG"
options["detect_direction"] = "true"
options["detect_language"] = "true"
options["probability"] = "true"
res = client.basicGeneral(image,options)
for colume in res['words_result']:
print(colume['words'])
程序使用的是百度的api,需要導入baidu-aip,并且需要APP_ID,API_KEY,SECRET_KEY
三個字符串。
百度智能雲
獲得APP_ID ,API_KEY,SECRET_KEY
此api還可以對圖片url,pdf識别,具體的使用可以參考下方的參數文檔
更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!