Pytesseract 无法读取简单数字

Pytesseract cannot read simple number

我正在尝试使用 pytesseract 从图像中识别两个数字。 由此 1

我把图片处理成这样 2 并将其提供给 pytesseract 并且它很容易工作。

但是当我想通过 tesseract 阅读这个 3 对此 4 它不起作用并且 return 空字符串

代码:

import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'


img = cv2.imread('grabbed.png')

rows, cols, channels = img.shape

imggray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, img = cv2.threshold(imggray, 220, 255, cv2.THRESH_BINARY_INV)
img = cv2.resize(img,(0,0),fx=3,fy=3)
img = cv2.GaussianBlur(img,(11,11),0)
img = cv2.medianBlur(img,9)
k = pytesseract.image_to_string(img, lang='eng', config='outputbase digits --dpi 300 --psm 13')
print(k)
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

1 - 检查方向。 pytesseract 需要完美的肖像图像。 2 - 使用膨胀和腐蚀 3 https://nanonets.com/blog/ocr-with-tesseract/ [看这个例子][1]