Python2.7 using tesseract for image recognition in Chinese and English

Source: Internet
Author: User

Background: win8.1 64-bit python2.7.13
I thought it would be very simple, the result in the configuration environment this piece spent a lot of time, stepped on a few pits, and finally read the English documents and log to solve the problem.
Open Web site
Https://pypi.python.org/pypi/pytesseract
Https://github.com/tesseract-ocr/tesseract/wiki
Https://github.com/tesseract-ocr/tesseract/wiki/Downloads
http://www.pythonware.com/products/pil/
Locate and download the installation tesseract-ocr-setup-4.00.00dev.exe file download Chinese training library Chi_sim.traineddata
Add the installation file path to path and path in the environment variable, add a tessdata_prefix to the system variable, the variable value or the file path
Mine is D:\programfiles\tesseract\Tesseract-OCR.
Open cmd install pip install pytesseract

Go to C:\Python27\Lib\site-packages, find PIL Uninstall and then go to download Pil-1.1.7.win32-py2.7.exe and install

#-*-coding:utf-8-*-Try:    ImportImageexceptImporterror: fromPILImportImageImportpytesseractimg= Image.open ('Test2.png') img.load () text= Pytesseract.image_to_string (IMG, lang='Chi_sim')Print(text)

Finally, look for a PNG picture and put it in the same directory as this file.

Several pits:
: From. Import VERSION, pillow_version, _plugins ueerror:attempted relative
Don't know what the ghost, then directly to the C:\Python27\Lib\site-packages\PIL to delete the re-install the library
Pytesseract.pytesseract.TesseractError: (1, U ' Error opening data file D:\\programfiles\\tesseract\\tesseract-ocr/chi _sim.traineddata ')
You need to place chi_sim.traineddata under the specified directory instead of $path \tessdata\tessconfigs
Summary: Look at the official tutorial Baidu search too old StackOverflow is also

Python2.7 using tesseract for image recognition in Chinese and English

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.