【问题标题】:python focus/crop to text on captcha imagepython焦点/裁剪到验证码图像上的文本
【发布时间】:2022-06-11 00:22:09
【问题描述】:

我最近一直在尝试使用 cv2、PIL 和 pytesseract 并尝试解决验证码。现在我已经能够通过使文本更加突出并减少噪音来优化reconition,但现在我试图从图像中裁剪出文本。

验证码示例:enhanced captcha

想要的输出:cropped captcha

cv2 中是否有库或函数可以自动执行此过程?

这是我现在的代码:

 
            file = cv2.imread(f"./captcha{num}.png")
            thresh, im_bw = cv2.threshold(file, 190, 260, cv2.THRESH_BINARY)
            _name = f'./enhanced{num}.png'
            b = cv2.imwrite(_name, im_bw)
            ocr = pytesseract.image_to_string(_name, config=self.config)
            captcha = str(ocr)
            
            if captcha != "" and not None or not None:
                _captcha = re.compile('[^a-zA-Z]').sub('', captcha).lower()
                
                d = enchant.Dict("en_US")
                if d.check(_captcha) == True:
                    
                    if len(_captcha) > 1:
                        print(_captcha)

谢谢

【问题讨论】:

标签: python opencv ocr captcha python-tesseract


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
  • 2017-05-22
  • 2010-11-24
  • 2015-08-10
  • 2011-06-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多