helenlee01

人工智能大法好,使用百度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站、快手、抖
音上随处可见关于它的视频。

 

分类:

技术点:

相关文章:

  • 2021-12-25
  • 2021-12-03
  • 2021-12-25
  • 2021-05-23
  • 2021-06-03
  • 2021-12-15
猜你喜欢
  • 2021-12-04
  • 2021-12-25
  • 2021-10-26
  • 2021-12-15
  • 2021-12-25
  • 2021-04-29
  • 2021-11-08
相关资源
相似解决方案