Python简单的验证码识别

来源:互联网 发布:家庭记账软件排行 编辑:程序博客网 时间:2024/06/05 06:09

1.安装 Python图像处理库 PIL     网上有下载的:PIL-1.1.7.win32-py2.7.exe


2.安装 tesseract-ocr :google的ocr识别引擎。下载


3.安装 pytesseract 

直接使用pip install pytesseract安装

接着编写xx.py:
try:    import pytesseract    from PIL import Imageexcept ImportError:    raise SystemExitimage = Image.open('captcha.png')captcha = pytesseract.image_to_string(image)print captcha
结果:


若是出现:
AttributeError: ‘NoneType’ object has no attribute ‘bands’
请进入D:\Python2.7\Lib\site-packages\PIL\Image.py 在1501行 改成:
def split(self):1495         "Split image into bands"1496 1497         self.load()1498         if self.im.bands == 1:1499             ims = [self.copy()]1500         else:1501             #self.load()1502             ims = [] 1503             for i in range(self.im.bands):1504                 ims.append(self._new(self.im.getband(i)))1505         return tuple(ims)
ok。
参考 www.waitalone.com
但是呢   主要还是简单的验证码可以识别。

0 0
原创粉丝点击