python - 使用 OpenCV 对 pytesseract OCR 进行图像预处理
问题描述
我想使用 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
我可以更改或添加到我的代码中以获得更准确的结果?
解决方案
推荐阅读
- android - Android Facebook 登录失败无一例外,只是“抱歉出了点问题”
- android - AAR 工件没有构建变体后缀
- javascript - 如何在我的 React Native 应用程序中为 Firebase 的生产和开发环境设置不同的环境?
- java - 另存为 Dailog 没有弹出
- c# - 如何制作可以访问其他计算机数据库的 C# Winforms 应用程序
- c# - 显示客户端的 ProcessList,但仅显示“应用程序”选项卡任务
- dialogflow-es - 尝试在语音助手中测试谷歌操作时发生履行错误
- c++ - 在范围内捕获变量
- linux - 使用 Bash 计算和打印两个日期之间的差异?
- php - Laravel 管理图像 URL 不包括端口并导致在编辑表单中找不到图像