Python Import image Error correction, recognition verification Code success

Source: Internet
Author: User

1, import image error, copy the PiL directory to the Site-packages directory, perform from PIL import image, you can

2. From pytesser import *, error, execute sys.path.append ("D:/software/15/python-packet/pytesser"), OK, then execute from pytesser import *, The error can not find the image module, modify the first sentence of the d:/software/15/python-packet/pytesser/pytesser.py to change from PIL import Image,ok

3, the error of the _imaging C module is not installed, install Pil-1.1.7.win32-py2.5,ok

4, installation Tesseract-ocr-setup-3.02.02.exe as if you can identify, directly run Tesseract-l Eng v4.jpg result, in the current directory result.txt can see the number of v4.jpg

5, the test under the Win7 success. Used to test the code picture file for v4.jpg, test program getverify.py, two files stored in the directory for D:\testcode\pythoncode, after the installation of successful Tesseract-ocr-setup-3.02.02.exe, Can see the directory tessdata, copy this directory to D:\testcode\pythoncode, test program getverify.py source code as follows

Import Tesseract
API = Tesseract. Tessbaseapi ()
Api. Init (".", "Eng", Tesseract. Oem_default)
Api. SetVariable ("Tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz")
Api. Setpagesegmode (tesseract. Psm_auto)

Mimgfile = "V4.jpg"
Mbuffer=open (Mimgfile, "RB"). Read ()
result = Tesseract. Processpagesbuffer (Mbuffer,len (mbuffer), API)
print ' result (processpagesbuffer) = ', result

Run command D:\testcode\pythoncode>d:\python27\python.exe getverify.py can see the numbers in V4.jpg

These two pictures can be named V4.jpg to experiment

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.