繁体   English   中英

为什么 Tesseract 无法检测到该图像中的单个数字?

[英]Why is Tesseract unable to detect the single digit in that image?

我有这张图片,我正在尝试用 Tesseract 阅读它:

在此处输入图像描述

我的代码是这样的:

pytesseract.image_to_string(im)

但是,我得到的只是LOW: 56 因此,Tesseract 无法读取第一行中的1 我还尝试指定一个只有数字的白名单,例如

pytesseract.image_to_string(im, config="tessedit_char_whitelist=0123456789.")

并用腐蚀处理图像,但没有任何效果。 有什么建议么?

在使用 Tesseract 时,提高 output 的质量是您的“圣经”。 特别是, 页面分割方法应始终明确设置。 在这里(大多数时候),我会选择--psm 6

假设一个统一的文本块。

即使没有对图像进行进一步预处理,您也已经获得了所需的结果:

import cv2
import pytesseract

image = cv2.imread('gBrcd.png')
text = pytesseract.image_to_string(image, config='--psm 6')
print(text.replace('\f', ''))
# 1
# LOW: 56
----------------------------------------
System information
----------------------------------------
Platform:      Windows-10-10.0.19041-SP0
Python:        3.9.1
PyCharm:       2021.1.1
OpenCV:        4.5.2
pytesseract:   5.0.0-alpha.20201127
----------------------------------------

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM