我试图从图像中检测文本 但是由于一些未知的原因失败了
import pytesseract as pt
from PIL import Image
import re
image = Image.open('sample.jpg')
custom_config = r'--oem 3 --psm 7 outbase digits'
number = pt.image_to_string(image, config=custom_config)
print('Number: ', number)
Number: 0 50 100 200 250 # This is the output that I am getting.
Expected --> 0,0,0,0,0,1,0,8
在原始/原始图像输入上使用tesseract进行OCR可能无法获得预期结果。 对于给定的图像,使用灰度转换,然后使用阈值操作,可以获得稍好的结果
要执行转换和阈值化操作,可以按如下方式使用ImageMagick:
一种更稳健的OCR方法是通过训练tesseract引擎discussed here
相关问题 更多 >
编程相关推荐