python-OCR Image recognition library --pytesseract

installation

After installing pytesseract ,, by writing code

import pytesseract
val = pytesseract.image_to_string(Image.open(imagePath))
print(val)

prompt:
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

The reason: the need to install tesseract pytesseract package before installation,

Finding Solutions: python3 optical character recognition module tesserocr and pytesseract

tesserocr installation reference link: https://github.com/sirfz/tesserocr

pytesseract installation reference link: https://github.com/madmaze/pytesseract

tesseract installation reference link: https://github.com/tesseract-ocr/tesseract/wiki

problem

  1. When using tesseract identify images, there is a problem
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.

First make sure that:
1, the installation Pillow, command pip install Pillow, will be installed in the Python folder Lib \ site-packages \ pytesseract this folder, there are pytesseract.py file
2, make sure you have Tesseract-OCR this does not seem to 64, 32 of the difference between
himself Python with 32-bit, install the OCR time, see no problem with that last 32-bit version, after installation, automatic generation of environment variables, see your path environment variable is whether there's tesseract
3, check the environment variable path and TESSDATA_PREFIX, path contains the installation directory tesseract, TESSDATA_PREFIX is tessdata tesseract installation directory, and then view the information
and then find a picture test, cmd, enter tesseract, suggesting there will be
a command tesseract d:/pic.gif resultto view the result of the content

  1. Use pytesseract picture identification carried out
    the following problems, find tesseract this environment variable is set to
    Solution:
    find pytesseract.py file, which will be designated "tesseract_cmd" field is the full path to the tesseract.exe, such as tesseract_cmd = r'c: \ Tesseract-OCR \ tesseract.exe '

PS: If you think you can, okay, so-so, not even too bad, then, can "focus or point like" look, this thanked!

Reproduced in: https: //www.jianshu.com/p/bda21d856aa3

Guess you like

Origin blog.csdn.net/weixin_33736048/article/details/91244017