Python2.7 +pytesser realizes the recognition method of simple captcha

  • 2020-06-19 11:00:44
  • OfStack

An example of Python2.7+pytesser is presented in this paper. To share for your reference, specific as follows:

First, install es5EN2.7

PIL tools installed, then download the address is: http: / / www pythonware. com/products pil /, the use of pytesser need PIL library support.

Then download pytesser, download address is: http: / / code google. com p/pytesser/downloads/list

The ES30en.google.com website is not accessible. Click here to download.

Finally, install pytesser:

1. Unzip pytesser. Copy the unzip file to Lib\ ES41en-ES42en in the Python installation directory and use it directly. For example, my installation directory is C:\Python27\Lib\ ES46en-ES47en.

2. Add two directories to the environment variable.

C:\Python27\Lib\site-packages
C:\Python27\Lib\site-packages\pytesser-v0.0.1

3. Add the.pth file (pytesser-v0.0.0.pth) under C:\Python27\ site-ES61en, which contains only the string "pytesser-v0.0.1".

Once you have done this, you are ready to write the Python script for image text recognition. The reference script is as follows:

Open "Run" by cmd. Type "Python" to enter Python interactive mode. Enter the following code:


from pytesser import *
import ImageEnhance
image = Image.open('D:\\xiehao\\workspace\\python\\5.png')
# use ImageEnhance Can enhance the image recognition rate 
enhancer = ImageEnhance.Contrast(image)
image_enhancer = enhancer.enhance(4)
print image_to_string(image_enhancer)

TIP:

After verification, this method can be used in the case of the text in the picture is very clear; When the interference line is more pictures, it will not work. Plus my programming foundation is not good, the identification of the verification code, it is impossible to do. / (ㄒ o ㄒ) / ~ ~

More about Python related content interested readers to view this site project: Python pictures skills summary, "Python data structure and algorithm tutorial", "Python Socket programming skills summary", "Python function using techniques", "Python string skills summary", "Python introduction and advanced tutorial" and "Python file and directory skills summary"

I hope this article has been helpful for Python programming.


Related articles: