码迷,mamicode.com
首页 > 编程语言 > 详细

Python验证码通过pytesser识别

时间:2017-07-23 00:54:40      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:下载   odi   images   ini   exe程序   sse   lin   com   war   

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)

 

Python验证码通过pytesser识别

标签:下载   odi   images   ini   exe程序   sse   lin   com   war   

原文地址:http://www.cnblogs.com/lxs1314/p/7223347.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!