精易论坛

标题: 识别图片上面文字的接口调用 [打印本页]

作者: deyliush    时间: 2020-5-6 14:31
标题: 识别图片上面文字的接口调用
import requests
from aip import AipOcr

image = requests.get('https://www.yisole.com/wp-content/uploads/2019/05/71576806261.jpg').content

APP_ID = '16149264'
API_KEY = 'yxYg9r4OuAs4fYvfcl8tqCYd'
SECRET_KEY = 'yWg3KMds2muFsWs7MBSSFcgMQl8Wng4s'
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
res = client.basicGeneral(image)
if 'words_result' in res.keys():
    for item in res['words_result']:
        print(item['words'])

else:
    APP_ID = '11756541'
    API_KEY = '2YhkLuyQGljPUYnmi*FgxOP'
    SECRET_KEY = '4rrHe2BF828bI8bQy6bLlx1MelXqa8Z7'
    client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
    res = client.basicGeneral(image)
    if 'words_result' in res.keys():
        for item in res['words_result']:
            print(item['words'])
    else:
        print(res)

图片4.png (165.89 KB, 下载次数: 0)

图片4.png





欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4