我想使用pytesseract为此类图像创建验证码求解器:
我使用OpenCV预处理图像,到目前为止,我具有以下内容:
代码:
import pytesseract
import cv2
img = cv2.imread('element.png')
ret,thresh1 = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)
thresh1 = cv2.blur(thresh1, (5, 5))
text = pytesseract.image_to_string(thresh1, lang='eng', config='-c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz --psm 6')
print(text)
cv2.imshow('Result1 bl', thresh1)
cv2.waitKey(0)
结果:
pytesseract会识别以下文本:SMVIN
我可以更改或添加什么代码以获得更准确的结果?