PyTesseract-识别简单图像中的数字

时间:2019-01-01 20:26:33

标签: python ocr tesseract python-tesseract

我正在尝试使用pytesseract来识别图像中的两个数字:

enter image description here

  • 我尝试了--psm 610
  • 我尝试了-c tessedit_char_whitelist=0123456789'

以上都不返回49数字。返回的我最近的是4,没有9

您有关于如何使tesseract识别它的任何提示吗?

3 个答案:

答案 0 :(得分:1)

您尝试了其他--oem吗?我还会尝试使用高于10的--psm

答案 1 :(得分:1)

尝试--psm 13 --oem 3oem = 1或2也应该这样做)

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)

您在我的计算机上预期的产出49

通过本地下载图像并启动

tesseract oAAXR.png output --oem 3 --psm 13 -l eng

我的tesseract --version提供的参考信息 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

答案 2 :(得分:0)

对我来说,以下命令仅返回4

tesseract oAAXR.png out --dpi 300 --psm 11 --oem 1 -c tessedit_char_whitelist=0123456789

使用:

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
相关问题