python gifmaze_Windows平台python验证码识别
參考:
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??創(chuàng)建二維碼圖片
python驗證碼識別庫安裝
1.安裝圖像處理庫PIL,即Python Image Library。
下載地址:http://www.pythonware.com/products/pil/
2.?安裝google OCR識別引擎pytesseract
以管理員身份運行命令提示行。
cd C:\Python27\Scripts
pip install pytesseract
單色無干擾驗證碼識別
對于完全單色沒有任何干撓的驗證碼,識別起來比較容易。代碼如下:
importosimportpytesseractimportImage
os.chdir('C:\Users\Administrator\Downloads\picture')
image= Image.open('verifycode.jpg')
vcode=pytesseract.image_to_string(image)print vcode
彩色有干擾驗證碼識別
中值過濾去噪。此種類型驗證碼包含了噪點,所以第一步就是去噪。
對圖像亮度進行加強處理。中值過濾時,不少噪點淡化了,但是如果直接轉(zhuǎn)換為單色,這些噪點又被強化顯示了,因此增加這一步對圖像亮度進行加強處理。
轉(zhuǎn)換為單色。即通過二值化,將低于閾值的設置為0,高于閾值的設置為1,從而實現(xiàn)將圖片變?yōu)楹诎咨:谏袼剌敵?,白色像素輸出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('1')
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
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結
以上是生活随笔為你收集整理的python gifmaze_Windows平台python验证码识别的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中希尔排序例题代码_十大经典排序算法最强
- 下一篇: python使用opencv_教你快速使