python使用tesseract识别验证码

版权声明:本文为博主原创文章,未经允许,不得转载,如需转载请注明出处 https://blog.csdn.net/ssjdoudou/article/details/83796792

写在最前面:

遇到了一个很无语的坑。

环境变量添加好以后,记得重启IDE--pycharm,不然死活会报错!!!

本来想用于我司运维平台的验证码识别的,结果截下来的图太模糊了,强大的tesseract也无能为力。。。

代码很简单,下面是安装步骤,具体的我的前面的博客有介绍

第一步:

用homebrew 在电脑上安装tesseract库 brew install tesseract

https://blog.csdn.net/ssjdoudou/article/details/83794522

第二步:

用pip安装支持python的tesseract 接口pip install pytesseract

扫描二维码关注公众号,回复: 3965961 查看本文章

第三步:

https://github.com/tesseract-ocr/tessdata下载中文数据集chi_sim.traineddat

然后做个简单的demo展示:

import pytesseract
import PIL
from PIL import Image

image = Image.open('codenew.jpg')
code = pytesseract.image_to_string(image,lang='chi_sim')
print(code)
7 36 4

Process finished with exit code 0

猜你喜欢

转载自blog.csdn.net/ssjdoudou/article/details/83796792