我在下面的代码中使用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秒。
有没有办法减少处理时间?
Pytesseract会写入并读取您传递的每个图像。运行35张图像时,这是不必要的。相反,你应该使用python tesseract API interface。这将明显加快。