tesseract: tesseract fails to read simple numbers
Current Behavior
I am using pytesseract (which calls /usr/bin/tesseract) to recognize numbers of a gas meter.
Unfortunately, this very often fails to read most numbers and is very unreliable.
The actual command to get the number string from the image is
pytesseract.image_to_string(img, lang='eng', config='--dpi 70 --psm 8 -c tessedit_char_whitelist=,0123456789')
Here is an example image (after some image processing):
When running this through tesseract (as described above), I just get “2734”… 😦
Any ideas how to improve this, given that there never will be anything but numbers from 0-9 in the image…?
Expected Behavior
Correctly read the numbers. For the image example, this should be “4428734”
Suggested Fix
No response
tesseract -v
tesseract 4.1.1 leptonica-1.79.0 libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 2.0.3) : libpng 1.6.37 : libtiff 4.1.0 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.1 Found AVX2 Found AVX Found FMA Found SSE Found libarchive 3.4.0 zlib/1.2.11 liblzma/5.2.4 bz2lib/1.0.8 liblz4/1.9.2 libzstd/1.4.4
Operating System
No response
Other Operating System
Ubuntu 20
uname -a
Linux myhost 4.4.0-19041-Microsoft #4355-Microsoft Thu Apr 12 17:37:00 PST 2024 x86_64 x86_64 x86_64 GNU/Linux
Compiler
No response
CPU
No response
Virtualization / Containers
Ubuntu in WSL2
Other Information
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 24 (3 by maintainers)
I just did a test and manually moved the individual digits closer to each other (without changing any of the black pixels) :
…and you are correct! Now I get this:
–psm 7: “4428734” –psm 8: “4428734”
So both report the same correct numbers only because the spacing. Interesting!