Pytesseract不能按预期识别文本。

问题描述 投票:0回答:1

我正在做一个项目,使用OCR我想从图片中读取文字。我使用tesseract来进行OCR,为了得到更好的结果,我添加了图像增强代码。但在OCR中,图像处理前的效果一般,预处理后没有结果。如果有人能帮助我,我会很高兴。丸子调度项目 (可编辑)

image-processing ocr project tesseract python-tesseract
1个回答
0
投票

我觉得你应该训练tesseract来识别你的笔迹。我使用的是原始数据,以下是我的结果。

import cv2
import pytesseract

img = cv2.imread("input2.jpeg", cv2.IMREAD_GRAYSCALE)
img = cv2.resize(img, None, fx=0.3, fy=0.3)
thresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)[1]
gauss = cv2.GaussianBlur(thresh, (3, 3), 0)

custom_config = r'-l eng --oem 3 --psm 6 '
text = pytesseract.image_to_string(gauss, config=custom_config)
print("detected: " + text)

cv2.imshow("img", img)
cv2.imshow("thresh", thresh)
cv2.imshow("gauss", gauss)

cv2.waitKey(0)
cv2.destroyAllWindows()

识别结果

detected: \We Staet With Good
Gecause all businesses should
be doing Something good .
© www.soinside.com 2019 - 2024. All rights reserved.