如何正确检测LetsGoDigital字体文本?

2024-06-09 00:59:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Windows 10上,我尝试从这张图像中提取数字

Input image

使用pytesseract语言库lets(参见https://github.com/adrianlazaro8/Tesseract_sevenSegmentsLetsGoDigital或LetsGoDigital,参见https://github.com/arturaugusto/display_ocr

我对我的图像进行了预处理(灰度、阈值和腐蚀),以获得:

Preprocessed image

但是

pytesseract.image_to_string(img, lang='lets')

是空的


Tags: https图像githubcom语言windowsdisplay数字
1条回答
网友
1楼 · 发布于 2024-06-09 00:59:55

您没有设置任何特定的page segmentation method。我会在这里选择 psm 6

Assume a single uniform block of text.

因此,即使没有进一步的预处理,我也能得到正确的结果:

import cv2
import pytesseract

img = cv2.imread('RcVbM.jpg')

text = pytesseract.image_to_string(img, lang='lets', config=' psm 6')
print(text.replace('\n', '').replace('\f', ''))
# 004200
                    
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
                    

相关问题 更多 >