Python验证码通过pytesser识别

Python安装包:

需要安装的包主要有两个: PIL 和 pytesser 、tesseract

(1)、安装PIL:下载地址:http://www.pythonware.com/products/pil/

下载后是一个exe程序,直接双击安装

(2)、pytesser:下载地址:http://code.google.com/p/pytesser/

pytesser 模块的安装:

下载后得到 “pytesser.zip”,是一个压缩文件,使用方法: 

1、在 “C:\Python27\Lib\site-packages” 路径下新建一个文件夹,命名 “pytesser” 。把 “pytesser.zip” 里的文件解压到该目录:

2、将 “pytesser.py” 改名为 “__init__.py”。

3、打开 “__init__.py” 文件,修改:tesseract_exe_name = 'C:\\Python27\\Lib\\site-packages\\pytesser\\tesseract' # Name of executable to be called at command line

4、pytesser 模块依赖于 PIL 模块,如果是按照上面的方法安装 PIL 的话,需要把 “init.py” 文件里的 “import Image” 改成 “from PIL import Image” 。

下载解压后直接放C:\Python27\Lib\site-packages,同时,新建一个pytesser.pth,内容就写,注意这里的内容一定要和pytesser这个文件夹同名,意思就是pytesser文件夹,pytesser.pth,及内容都要一样!

(3)、Tesseract OCR engine下载:http://code.google.com/p/tesseract-ocr/

下载后解压,tessdata文件夹,用其替换掉pytesser解压后的tessdata文件夹即可。(就上面的pytesser文件夹)

代码如下:

1 #-*- coding:utf-8 -*-
2 __author__ = "carry"
3 from PIL import Image
4 from pytesser import *
5 
6 image = Image.open('xx.jpg')
7 print image_to_string(image)

 

转载于:https://www.cnblogs.com/lxs1314/p/7223347.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值