Python practice === use python to recognize Chinese Characters in Images,

Source: Internet
Author: User

Python practice === use python to recognize Chinese Characters in Images,

Modules to be installed

PIL

pytesseract

Tools to be downloaded:

Http://download.csdn.net/download/bo_mask/10196285

Download and unzip the package and install itDefaultPath, such as 1:

 

 

And copy and decompress the fileChi_sim.traineddataFile to installation pathC: \ Program Files (x86) \ Tesseract-OCR \ tessdata2, Figure 3:

Okay, if you have installed all of the above, there is still the last step to change the configuration file, as shown in Figure 4:

After opening, comment out the original one and add:

# Change this if tesseract is not in your path, OR IS NAMED DIFFERENTLY
# Tesseract_cmd = 'tesseract'

Tesseract_cmd = u'c:/Program Files (x86)/Tesseract-OCR/tesseract.exe '# This path is the path after your installation, corresponding to the path in Figure 1

Save! Environment configuration complete ~

 

 

For example, save as 111.png:

 

#test.py

from PIL import Imageimport pytesseracttext=pytesseract.image_to_string(Image.open('111.png'),lang='chi_sim')print(text)

Execution result:

 

(-.-|... ....

 

 

Summary:

 

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.