Pytesseract太慢了.如何使它更快地处理图像? [英] Pytesseract is too slow. How can I make it process images faster?
本文介绍了Pytesseract太慢了.如何使它更快地处理图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在以下代码中使用pytesseract:
I am using pytesseract in the below code:
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秒.
The list contains names of images from a folder (2408*3506 & 300 res Gray-scaled). Unfortunately for around 35 images the total processing time is around 1400-1500 seconds.
有没有一种方法可以减少处理时间?
Is there a way I can reduce the processing time?
推荐答案
Pytesseract写入和读取传递给它的每个图像.当运行35张图像时,这是不必要的.相反,您应该使用 python tesseract API接口.这样会更快.
Pytesseract writes and reads every image you pass it. This is unnecessary when running 35 images. Instead, you should use a python tesseract API interface. This will be significantly faster.
这篇关于Pytesseract太慢了.如何使它更快地处理图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文