为什么pytesseract无法在此简单图像中识别数字? [英] Why does pytesseract fail to recognize digits in this simple image?

查看:1923
本文介绍了为什么pytesseract无法在此简单图像中识别数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to use pytesseract to recognize two numbers from an image:

  • 我尝试了--psm 610
  • 我尝试了-c tessedit_char_whitelist=0123456789'
  • I have tried --psm 6 up to 10
  • I have tried -c tessedit_char_whitelist=0123456789'

以上都不返回49号.我得到的最近的是返回的4没有9

None of the above returns 49 number. Closest I got is returned 4 without 9

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

Do you have any tips about how to make tesseract recognize it ?

推荐答案

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

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)

在您的机器上按预期输出49.

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

我的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.

这篇关于为什么pytesseract无法在此简单图像中识别数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆