人工智能大法好,使用百度api批量识别图片上的文字:
这是是批量识别,统统放进一个文件夹就OK啦~
from aip import AipOcr
import os
APP_ID = \'?\'
API_KEY = \'?\'
SECRET_KEY = \'?\'
aipOcr = AipOcr(APP_ID, API_KEY, SECRET_KEY)
def get_file_content(filePath):
with open(filePath, \'rb\') as fp:
return fp.read()
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
if \'jpg\' in name:
filePath = os.path.join(root, name)[2:]
options = {
\'detect_direction\': \'true\',
\'language_type\': \'CHN_ENG\',
}
result = aipOcr.webImage(get_file_content(filePath),options)
print(result)
for i in result[\'words_result\']:
print(i[\'words\'])
运行结果:
消除恐惧的最好办法是面对恐惧!"这不是什么名
人毒鸡汤,是最近霸屏B站弹幕的ν奥利给“的励志
语录。
奥利给究竟是什么梗?
奥利给″一词彻底火了。一时间,B站、快手、抖
音上随处可见关于它的视频。