Pytesseract is too slow. How can I make it process images faster?

佐手、 提交于 2019-12-24 00:22:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!