Pytesseract太慢了。如何让它更快地处理图像?

问题描述 投票:1回答:1

我在下面的代码中使用pytesseract:

    def fnd():
    for fname in list:
        x = None
        x = np.array([np.array(PIL.Image.open(fname))])
        print x.size
        for im in x:
                     txt = pytesseract.image_to_string(image=im).encode('utf-8').strip()
                     open("Output.txt","a+").write(txt)
                     with open("Output.txt") as openfile:                        
                         for line in openfile:
                             for part in line.split():
                                 if "cyber" in part.lower():
                                     print(line)
                                     return

该列表包含文件夹中的图像名称(2408 * 3506和300 res灰度)。不幸的是,对于大约35张图像,总处理时间约为1400-1500秒。

有没有办法减少处理时间?

python ocr tesseract python-tesseract
1个回答
0
投票

Pytesseract会写入并读取您传递的每个图像。运行35张图像时,这是不必要的。相反,你应该使用python tesseract API interface。这将明显加快。

© www.soinside.com 2019 - 2024. All rights reserved.