使用pytesseract解决困难的验证码

问题描述 投票:-1回答:1

我是pytesseract的初学者。

我尝试从这些验证码图像中获取字母:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS8wOVA1Ry5naWYifQ==” alt =“在此处输入图像描述”>

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9hWEE0Ni5naWYifQ==” alt =“在此处输入图像描述”>

“在此处输入图像描述”

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9yVFhrdS5naWYifQ==” alt =“在此处输入图像描述”>

import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
pytesseract.image_to_string(Image.open('C:/Users/user/Desktop/download (2).png'))

但是它给了我“”作为输出。

python tesseract python-tesseract
1个回答
1
投票

您可能想转义空格和/字符。我怀疑这可能是导致问题的原因。

pytesseract.pytesseract.tesseract_cmd = r'C:\Program\ Files\Tesseract-OCR\tesseract.exe'
pytesseract.image_to_string(Image.open('C:\/Users\/user\/Desktop\/download\ (2).png'))

我希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.