How does python recognize text in pictures? Here is a case with detailed steps:
Installation of module package:
1. Install PIL: pip install Pillow
2. Install pytesser3: pip install pytesser3
3. Install pytesseract: pip install pytesseract
4. Install autopy3:
Install wheel first: pip install wheel
Download autopy3-0.51.1-cp36-cp36m-win_amd64.whl [Click to open the link]
Execute command: pip install E :\360 Safe Browser Download\autopy3-0.51.1-cp36-cp36m-win_amd64.whl
5. Install Tesseract-OCR: Search Tesseract-OCR directly on Baidu and download it
here It should be noted that after Tesseract-OCR is installed, it will not be added to the environment variable path by default.
There are two solutions: (First find the Tesseract-OCR installation folder, and then find the tesseract.exe file)
My absolute path here is: D:\python\Tesseract-OCR\tesseract.exe
①Add this path to the environment variable path (but this is what I do Yes, but PyCharm still reports an error)
②Find the pytesseract.py file
My here is C:\Users\admin\AppData\Local\Programs\Python\Python36\Lib\site-packages \pytesseract\pytesseract.py
Modify tesseract_cmd in the file to the absolute path above
Get to the point, how to recognize text in images
Uehara Picture: (This is a classic line from The Pianist on the Sea)
Next we need to use python’s pytesseract to identify the characters in the picture
# _*_ coding:utf-8 _*_ import pytesseract from PIL import Image __author__ = 'admin' im = Image.open(r'C:\Users\admin\Desktop\example.png') print(pytesseract.image_to_string(im))
Rendering
The above is the detailed content of How to recognize text in pictures in python. For more information, please follow other related articles on the PHP Chinese website!