Original Python uses Pytesseract library identification verification Code (MAC system)

Source: Internet
Author: User


1. Install Python

Brew Install Python


2. Installation PIL and image format support

Download
Http://www.pythonware.com/products/pil/index.htm

Extract
Tar-xzf imaging-1.1.7.tar.gz

Installing PIL
CD Imaging-1.1.7
sudo python setup.py install

Install Picture format support
Brew Install Libpng
Brew Install JPEG
Brew Install Libtiff

(Note: PIL still cannot support TIFF-formatted images after installing Libtiff, for reasons not yet known)


3. Installing Leptonica

Brew Install Leptonica


4. Installing TESSERACT-OCR

Brew Install Tesseract


5. Installing the Pytesseract Library

Installing the PIP tool
sudo easy_install pip

Installing Pytesseract
sudo pip install pytesseract

6. Write the Python script and run it

Import pytesseractfrom PIL Import imageimage = Image.open (' yzm.png ') image.load () image.split () Vcode = Pytesseract.image _to_string (image) Print Vcode

Where Yzm.png is the same directory as the Captcha picture, and the py script

The py script is saved as yzm.py and runs

Python yzm.py

Show results

Original Python uses Pytesseract library identification verification Code (MAC system)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.