Python Verification Code identification

Source: Internet
Author: User

I. Preparation and code examples

1, PIL, Pytesser, tesseract

(1) Install pil::http://www.pythonware.com/products/pil/(csdn download)

After the download is an EXE, directly double-click the installation, it will automatically install into the C:\Python27\Lib\site-packages,

(In fact, with PIP installed, pip install PIL or pip install pillow It forget, you can check the next look! )

(2) pytesser::http://code.google.com/p/pytesser/, (csdn download)

After the download decompression directly put C:\Python27\Lib\site-packages (depending on the Python path you installed different), at the same time, create a new pytesser.pth, the content is written Pytesser, Note that the content here must be the same name as the Pytesser folder, meaning that the Pytesser folder, Pytesser.pth, and content are the same!

     

(3) Tesseract OCR engine Download: http://code.google.com/p/tesseract-ocr/(csdn download)

After downloading, unzip, Tessdata folder, use it to replace the Pytesser extracted Tessdata folder. (On the Pytesser folder above)

          

In fact, as long as the extracted files are copied directly in the past, you will be prompted whether to overwrite, you can directly overwrite. PS: At first I just tessdata copy the past overlay, and finally redefine the script's working path or not full coverage, then OK

Note: To read the verification code picture needs to be saved in C:\Python27\Lib\site-packages\pytesser This directory, that is, pytesser this installation package file, no test does not save where will report what error, have time to try!

Here is the code for the test:

1Rom PytesserImport*2 ImportOS3Os.chdir ('C:\Python27\Lib\site-packages\pytesser')#The working directory under the current script; the equivalent of a CD under the shell4My_math =OS.GETCWD ()5 PrintMy_math6 7Math ='fnord.tif'8im =image.open (Math)9 PrintImage_to_string (IM)

If you do not redefine the script's working path, it will appear with the following error:

        

Reference:

Http://www.voidcn.com/blog/u014265347/article/p-5036019.html

http://blog.csdn.net/evankaka/article/details/49533493

Python Verification Code identification

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.