-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow recognition due to multithreading issues in Tesseract 4 and 5 #2
Comments
I need some info to try to reproduce the issue:
|
Kubuntu 19.10 You can just use the use the any block of text. I was going to record a gif, but my screen recorder is crapping out for some reason. I took me about two minutes to recognize this block of text, with ffmpeg and dpOCR taking up ~35% of CPU each throughout the process:
|
Is "Run executable" action enabled? |
My env is the same as yours except that you have only one option in your languages list (english), whereas I have all the international languages. I only have English selected for recognition however. But maybe it's still looping through all the languages trying to find the right one? |
action_add_to_history true Operating System: Kubuntu 19.04 |
Well no, it's the regular package. It can't be tesseract anyway, because my bash script takes under two seconds and it uses tesseract too. Maybe you just have a really fast processor? My laptop is five years old, with intergrated graphics. I notice that ffmpeg hovers at 30% CPU for a while. Let me know if there is any other way to diagnose what's going on inside your program. |
There are some bug reports (like the following) about performance drops in Tesseract 4; the issues are related to CPU instructions (see Hardware and CPU Requirements), but I don't think that's your case because my CPU is even older than yours and only supports SSE4. dpScreenOCR doesn't do anything special compared to the command-line tesseract, except that it preprocess the image to improve OCR quality: converts it to grayscale, scales up 4 times, and finally performs unsharp masking. Of course, the pre-processing step takes some time (almost 2 seconds for whole my 1600x900 screen), and OCRing 4 times bigger image is slightly slower than the original, but the difference is not that high, at least not 10 times. In fact, on my machine OCR with the command-line tool is slower for the original (small) image compared to the preprocessed (4 times bigger): 2.348s vs 0.656s. Anyway, this case is simple to test: download the following 2 images and try to send them to the command-line tesseract. The first is the original, the second is the preprocessed one: |
Yep, it's tesseract. Sorry for the confusion (I apparently it got updated since I used it in my OCR script the last time, but I was not aware so remained under the impression that tesseract was still working fine). With version 4, tesseract is completely unusable. Times are 1m14s for the smaller file and 1m26s for the larger file.
So all the instructions are supported but for some reason it's relying on raw C++. |
@danpla, I filed the tesseract bug here. Again, apologies for not realizing tesseract was the problem sooner. |
No worries. Thanks for using dpScreenOCR. |
@danpla it looks like it may be a good idea to disable multicore - the potential gains are very tiny but the potential slowdown is two orders of magnitude. I am not sure what other apps using tesseract do exactly but they work fine op my system (eg gimagereader, paperwork). Presumably they prevent tesseract from maxing out the core count. |
Summary for users experiencing the same problem: you need to set the OMP_THREAD_LIMIT environment variable to 1 before running dpScreenOCR. See the Troubleshooting section of the manual for details. |
Starting from version 1.3.0, dpScreenOCR will automatically set OMP_THREAD_LIMIT on start. |
Same here. After updating to Ubuntu 22.04, gImageReader became incredibly slow for me. Dev manisandro was very helpful and led me to a quick and dirty cli solution for running on a single thread. 'Works wonderfully for me.
If you want to check that you actually are running on one thread, type:
Then run gImageReader:
Et voilà :o) |
Since dpScreenOCR 1.3.0, you no longer need to set |
Even testing with one language it takes ten seconds to recognize. OCR'ing the same image with tesseract via the commandline takes under a second.
I have it set to only recognize one language in both case, so am not sure what's causing the delay in dpscreenocr.
The text was updated successfully, but these errors were encountered: