问题
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
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?
回答1:
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.
来源:https://stackoverflow.com/questions/52070514/pytesseract-is-too-slow-how-can-i-make-it-process-images-faster