我在下面的代码中使用了 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 分辨率灰度)。不幸的是,对于大约 35 张图像,总处理时间约为 1400-1500 秒。
有什么方法可以缩短处理时间?
请您参考如下方法:
Pytesseract 写入和读取您传递给它的每个图像。这在运行 35 个图像时是不必要的。相反,您应该使用 python tesseract API interface .这将明显更快。
