首页 > 解决方案 > pytesseract 无法处理数字图像

问题描述

我想使用 pytesseract 对以下图像进行分类:

数字 5 的图像

但它将其归类为“T”。

这是代码:

txt = pytesseract.image_to_string(image, config='-psm 10')

标签: pythonopencvpython-tesseract

解决方案


image = cv2.imread('image.jpg', cv2.IMREAD_UNCHANGED);
image = cv2.bitwise_not(image)
text = pytesseract.image_to_string(image, lang='eng',config='--tessdata-dir "/tessdata/data/" --oem 2 --psm 6')
print(text)

推荐阅读