我尝试在下面的代码中使用Tessract来提取图像的两行。我试着改善图像质量,但没用。在
有人能帮我吗?在
from PIL import Image, ImageEnhance, ImageFilter
import pytesseract
img = Image.open(r'C:\ocr\test00.jpg')
new_size = tuple(4*x for x in img.size)
img = img.resize(new_size, Image.ANTIALIAS)
img.save(r'C:\\test02.jpg', 'JPEG')
print( pytesseract.image_to_string( img ) )
鉴于@barny的评论,我不知道这是否有效,但您可以尝试下面的代码。我创建了一个脚本来选择显示区域并将其扭曲为一个直图像。接下来是一个字符的黑白蒙版的阈值,结果会被清理一点。在
试试看能不能提高认知度。如果是这样的话,还可以看看中间阶段,这样你就能理解所有发生的事情。在
更新:Tesseract似乎更喜欢白色背景下的黑色文本,并将结果倒置和放大。在
结果:
更新结果:
代码:
相关问题 更多 >
编程相关推荐