【问题标题】:Python - Tesseract - Recognize this captchaPython - Tesseract - 识别这个验证码
【发布时间】:2021-07-16 14:12:30
【问题描述】:

我正在尝试解析验证码的文本,但不幸的是它并不完美。 我在 Windows 10 x64 下使用 pytesseract 0.3.8、Python 3.9 和 tesseract v5.0.0-alpha.20210506。

Captcha1

Captcha2

Captcha3

我的代码:

image = Image.open(path).convert('RGB')
    image = ImageOps.autocontrast(image)
 
    fct.creerDossierSiInexistant("captchas")
    filename = "{}.png".format(os.getpid())
    image.save("captchas\\" + filename)
    pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'
    
    text = pytesseract.image_to_string(Image.open("captchas\\" + filename))

谢谢!

【问题讨论】:

  • 仅对图像进行调整(如阈值和锐化)并调用 tesseract.对于您这样的任务,最好训练 tesseract 或应用 cv2 方法。作为一种快速修复,您也可以尝试拆分图像上找到的字符并在每个字符上运行 tesseract。看看stackoverflow.com/questions/56305445/…

标签: tesseract captcha python-tesseract


【解决方案1】:

Tesseract 并非旨在破解验证码。 Tesseract 需要清晰的图像,没有最少的伪影。

如果实施了验证码,那是有原因的。不要破坏它,而是联系网站管理员以同意合作而不是破坏规则。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-11
    • 2021-11-18
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多