参考:

http://oatest.dragonbravo.com/Authenticate/SignIn?returnUrl=%2f

http://drops.wooyun.org/tips/6313

http://blog.csdn.net/nwpulei/article/details/8457738

http://www.pythonclub.org/project/captcha/python-pil

http://blog.csdn.net/csapr1987/article/details/7728315  创建二维码图片

python验证码识别库安装

1.安装图像处理库PIL,即Python Image Library。

下载地址:http://www.pythonware.com/products/pil/

2. 安装google OCR识别引擎pytesseract

以管理员身份运行命令提示行。

cd C:\Python27\Scripts

pip install pytesseract

单色无干扰验证码识别

对于完全单色没有任何干挠的验证码,识别起来比较容易。代码如下:

import os
import pytesseract
import Image os.chdir('C:\Users\Administrator\Downloads\picture')
image = Image.open('verifycode.jpg')
vcode = pytesseract.image_to_string(image)
print vcode

彩色有干扰验证码识别

  1. 中值过滤去噪。此种类型验证码包含了噪点,所以第一步就是去噪。
  2. 对图像亮度进行加强处理。中值过滤时,不少噪点淡化了,但是如果直接转换为单色,这些噪点又被强化显示了,因此增加这一步对图像亮度进行加强处理。
  3. 转换为单色。即通过二值化,将低于阈值的设置为0,高于阈值的设置为1,从而实现将图片变为黑白色。黑色像素输出1,白色像素输出0。

代码如下:

os.chdir('C:\Users\Administrator\Downloads\picture')
image = Image.open('vcode.gif')
images = image.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(images)
images = enhancer.enhance(2)
images = images.convert('')
images.show()

验证码图像处理脑图如下:

附上pytesseract简介:

Metadata-Version: 1.1
Name: pytesseract
Version: 0.1.6
Summary: Python-tesseract is a python wrapper for google's Tesseract-OCR
Home-page: https://github.com/madmaze/python-tesseract
Author: Matthias Lee
Author-email: pytesseract@madmaze.net
License: GPLv3
Description: Python-tesseract is an optical character recognition (OCR) tool for python.
        That is, it will recognize and "read" the text embedded in images.
       
        Python-tesseract is a wrapper for google's Tesseract-OCR
        ( http://code.google.com/p/tesseract-ocr/ ).  It is also useful as a
        stand-alone invocation script to tesseract, as it can read all image types
        supported by the Python Imaging Library, including jpeg, png, gif, bmp, tiff,
        and others, whereas tesseract-ocr by default only supports tiff and bmp.
        Additionally, if used as a script, Python-tesseract will print the recognized
        text in stead of writing it to a file. Support for confidence estimates and
        bounding box data is planned for future releases.
       
       
        USAGE:
        ```
         > try:
         >     import Image
         > except ImportError:
         >     from PIL import Image
         > import pytesseract
         > print(pytesseract.image_to_string(Image.open('test.png')))
         > print(pytesseract.image_to_string(Image.open('test-european.jpg'), lang='fra'))
        ```
       
        INSTALLATION:
       
        Prerequisites:
        * Python-tesseract requires python 2.5 or later or python 3.
        * You will need the Python Imaging Library (PIL).  Under Debian/Ubuntu, this is
          the package "python-imaging" or "python3-imaging" for python3.
        * Install google tesseract-ocr from http://code.google.com/p/tesseract-ocr/ .
          You must be able to invoke the tesseract command as "tesseract". If this
          isn't the case, for example because tesseract isn't in your PATH, you will
          have to change the "tesseract_cmd" variable at the top of 'tesseract.py'.
          Under Debian/Ubuntu you can use the package "tesseract-ocr".
         
        Installing via pip:  
        See the [pytesseract package page](https://pypi.python.org/pypi/pytesseract)  
        ```
        $> sudo pip install pytesseract  
        ```
       
        Installing from source:  
        ```
        $> git clone git@github.com:madmaze/pytesseract.git  
        $> sudo python setup.py install 
        ```
       
        LICENSE:
        Python-tesseract is released under the GPL v3.
       
        CONTRIBUTERS:
        - Originally written by [Samuel Hoffstaetter](https://github.com/hoffstaetter)
        - [Juarez Bochi](https://github.com/jbochi)
        - [Matthias Lee](https://github.com/madmaze)
        - [Lars Kistner](https://github.com/Sr4l)
Keywords: python-tesseract OCR Python
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3

Windows平台python验证码识别的更多相关文章

  1. Python+Request库+第三方平台实现验证码识别示例

    1.登录时经常的出现验证码,此次结合Python+Request+第三方验证码识别平台(超级鹰识别平台) 2.首先到超级鹰平台下载对应语言的识别码封装,超级鹰平台:http://www.chaojiy ...

  2. python验证码识别

    关于利用python进行验证码识别的一些想法 用python加“验证码”为关键词在baidu里搜一下,可以找到很多关于验证码识别的文章.我大体看了一下,主要方法有几类:一类是通过对图片进行处 理,然后 ...

  3. Python 验证码识别-- tesserocr

    Python 验证码识别-- tesserocr tesserocr 是 Python 的一个 OCR 识别库 ,但其实是对 tesseract 做的一 层 Python API 封装,所以它的核心是 ...

  4. 【转】Python验证码识别处理实例

    原文出处: 林炳文(@林炳文Evankaka) 一.准备工作与代码实例 1.PIL.pytesser.tesseract (1)安装PIL:下载地址:http://www.pythonware.com ...

  5. Python 验证码识别(别干坏事哦...)

    关于python验证码识别库,网上主要介绍的为pytesser及pytesseract,其实pytesser的安装有一点点麻烦,所以这里我不考虑,直接使用后一种库. python验证码识别库安装 要安 ...

  6. Windows平台Python Pyramid实战从入门到进阶:第一个服务

    Pyramid是比较流行的Python Web 框架,比较灵活,功能也很强大.最近项目上用到,便打算学习一下.网上教程比较少,而且很多都是针对linux平台的,我是windows土著所以对那些linu ...

  7. windows平台python 2.7环境编译安装zbar

    最近一个项目需要识别二维码,找来找去找到了zbar和zxing,中间越过无数坑,总算基本上弄明白,分享出来给大家. 一.zbar官方介绍 ZBar 是款桌面电脑用条形码/二维码扫描工具,支持摄像头及图 ...

  8. Python验证码识别处理实例(转载)

    版权声明:本文为博主林炳文Evankaka原创文章,转载请注明出处http://blog.csdn.net/evankaka 一.准备工作与代码实例 1.PIL.pytesser.tesseract ...

  9. Python验证码识别处理实例(转)

    一.准备工作与代码实例 1.PIL.pytesser.tesseract (1)安装PIL:下载地址:http://www.pythonware.com/products/pil/(CSDN下载) 下 ...

随机推荐

  1. Android:JNI与NDK(二)交叉编译与动态库,静态库

    欢迎关注公众号,第一时间获取最新文章: 本篇目录 一.前言 本篇主要以window开发环境为背景介绍一下NDK开发中需要掌握的交叉编译等基础知识,选window系统主要是照顾大多数读者,mac ,li ...

  2. vue教程二 vue组件(2)

    每个组件都可以有自己的data.methods.computed和您之前看到的所有内容—就像Vue实例本身一样. 您可能已经注意到了组件和Vue实例之间的一个细微差别:Vue实例上的数据属性是一个对象 ...

  3. 基于zookeeper集群的云平台-配置中心的功能设计

    最近准备找工作面试,就研究了下基于zookeeper集群的配置中心. 下面是自己设想的关于开源的基于zookeeper集群的云平台-配置中心的功能设计.大家觉得哪里有问题,请提出宝贵的意见和建议,谢谢 ...

  4. Activiti6系列(3)- 快速体验

    一.部署启动activiti 1.部署,将两个war包拷贝到Tomcat下即可. 2.启动tomcat,访问http://127.0.0.1:8080/activiti-app 默认账号密码:admi ...

  5. 【POJ - 2431】Expedition(优先队列)

    Expedition 直接中文 Descriptions 一群奶牛抓起一辆卡车,冒险进入丛林深处的探险队.作为相当差的司机,不幸的是,奶牛设法跑过一块岩石并刺破卡车的油箱.卡车现在每运行一个单位的距离 ...

  6. 转载 | SVG向下兼容优雅降级方法

    本文引自:http://www.zhangxinxu.com/wordpress/2013/09/svg-fallbacks/ 1.svg image标签降级技术 <svg width=&quo ...

  7. jQuery中的append中含有onClick的问题

    在jQuery中,当append中含有onClick时,点击事件无效果.需要在append完之后再额外绑定点击事件.

  8. lumen 路由访问路径

    项目目录/public/index.php/接你设置的路由 比如设置了 $app->get('/test', function () use ($app) {    return $app-&g ...

  9. Docker系列之.NET Core入门(三)

    前言 在Docker生态系统中除了上一节所讲解的基本概念,还有其他专业术语,本文我们将一笔带过,同时会开始陆续进入到在.NET Core中使用Docker. 专业术语 Docker Engine(Do ...

  10. MVC + EFCore 完整教程19-- 最简方法读取json配置:自定义configuration读取配置文件

    问题引出 ASP.NET Core 默认将 Web.config移除了,将配置文件统一放在了 xxx.json 格式的文件中. 有Web.config时,我们需要读到配置文件时,一般是这样的: var ...