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