Python image Recognition-ai Chapter

Source: Internet
Author: User
Tags image processing library

First, install Pytesseract and PIL

PIL full name : Python Imaging library,python image processing Library, which supports a variety of file formats and provides powerful image processing and graphics processing capabilities.

Since PIL only supports Python 2.7, a pillow library has been created on PIL basis, supporting the latest Python 3.x.

1. PIP Command Installation

Pip Install Pytesseract

Pip Install Pillow

2, using the Pycharm Editor installation, the following procedures.  

Installation succeeded:

When installing Pytesseract, install pillow at the same time, so we just need to install pytesseract.

3. Attempt to run, error, such as, cause: No recognition engine installed TESSERACT-OCR

Second, install the recognition engine TESSERACT-OCR

1.Tesseract is an open-source OCR engine. Tesseract was originally designed for English recognition, with an improved engine and training system that can handle other languages and UTF-8 characters. Tesseract 3.0 can handle any Unicode character, but it does not work well in all languages. Tesseract is slower on large character set languages (such as Chinese), but works well.

Download Link: https://pan.baidu.com/s/1J0HNoVhX8WexS_5r0k2jDw Password: ywc3

because TESSERACT-OCR does not support Chinese recognition by default.

Files to be downloaded: Chi_sim.traineddata into the TESSERACT-OCR installation directory D:\Program files (x86) \tesseract-ocr\tessdata,

2, after the installation completed TESSERACT-OCR, you need to do a configuration.

in the Python installation directory (e.g. D:\Python35\Lib\site-packages\pytesseract) Modify the pytesseract.py file.

You can also open Pytesseract source files quickly via Pycharm,ctrl+b:

3. Try to run, the following error occurred: Pytesseract.pytesseract.TesseractError: (1, ' Error opening data file \\Program Files (x86) \\Tesserac T-ocr\\chi_sim.traineddata sure the TESSDATA_PREFIX environment variable are set to your "Tessdata" directory. Failed loading language \ ' chi_sim\ ' tesseract couldn\ ' t load any languages! Could not initialize tesseract. ')  

4. Workaround: Add the path to the parent directory of the Tessdata directory: (the default is the TESSERACT-OCR installation directory) to the TESSDATA_PREFIX environment variable, such as:

    Note: You need to reopen the Pycharm editor (IDE) after configuring the environment variables.

5. Test results: Image recognition success!

But the recognition rate is not very high, later re-tuning.

Python image Recognition-ai chapter

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.