Try --psm 13 --oem 3
( oem
= 1 or 2 should do also)
import pytesseract
from PIL import Image
import requests
import io
response = requests.get('https://i.stack.imgur.com/oAAXR.png')
text = pytesseract.image_to_string(Image.open(io.BytesIO(response.content)), lang='eng',
config='--psm 13 --oem 3 -c tessedit_char_whitelist=0123456789')
print(text)
yields 49
as you expect on my machine.
I get the same result by downloading the image locally and firing
tesseract oAAXR.png output --oem 3 --psm 13 -l eng
For reference my tesseract --version
gives tesseract 4.0.0 leptonica-1.77.0 libgif 5.1.4: libjpeg 8d (libjpeg-turbo 2.0.1): libpng 1.6.36: libtiff 4.0.10: zlib 1.2.11: libwebp 1.0.1 Found AVX2 Found AVX Found SSE
.
Have you tried different --oem
? I would also try to use a --psm
higher than 10.
For me the following command just returns 4
:
tesseract oAAXR.png out --dpi 300 --psm 11 --oem 1 -c tessedit_char_whitelist=0123456789
Using:
tesseract 4.1.1-rc2-17-g6343
leptonica-1.76.0
libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.2) : libpng 1.6.36 : libtiff 4.0.10 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
Found AVX2
Found AVX
Found FMA
Found SSE
Found libarchive 3.3.3 zlib/1.2.11 liblzma/5.2.4 bz2lib/1.0.6 liblz4/1.8.3 libzstd/1.3.8
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.