We recognize the above Chinese characters.
And python libraries to install software tesseract
https://www.cnblogs.com/sea-stream/p/10961580.html
Then create a new folder test, the picture above is placed inside a folder, and then create a test file
Write the following
Coding = UTF- # . 8 from the PIL Import Image Import pytesseract # above is the leader packet, only able to achieve the following line image character recognition text = pytesseract.image_to_string (Image.open ( ' xxx.png ' ), lang = ' chi_sim ' ) Print (text)
Contents are as follows:
Operational errors may occur:
C:\Users\k\Desktop\test>python test.py Traceback (most recent call last): File "test.py", line 5, in <module> text=pytesseract.image_to_string(Image.open('xxx.png'),lang='chi_sim') File "C:\Users\k\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 309, in image_to_string }[output_type]() File "C:\Users\k\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 308, in <lambda> Output.STRING: lambda: run_and_get_output(*args), File "C:\Users\k\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 218, in run_and_get_output run_tesseract(**kwargs) File "C:\Users\k\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 194, in run_tesseract raise TesseractError(status_code, get_errors(error_string)) pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:\\Program Files (x86)\\Tesseract-OCR/tessdata/chi_sim.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory. Failed loading language \'chi_sim\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')
Because tesseract-ocr default does not support Chinese recognition. Will be downloaded to file: chi_sim.traineddata into the Tesseract-OCR installation directory D: \ Program Files (x86) Tesseract-OCR \ tessdata under \
Link: https: //pan.baidu.com/s/1c-fveIYnm1sQHxX9WRpUZw
extraction code: 9ovq
Run again
python test.py
Here is the output
C: \ the Users \ k \ Desktop \ the Test> Python test.py
winds and days of high ape Xiao Zhong 'For Mai Mai take less ugly mouth bow fly.
u edge at Los Wood rustling 'No 〖Yangtze River rolling by.
Wan Wo sad fire Often animals' annual and sick alone on stage.
Hard frost bitter hate Ying Shu unitary slag down new wood does not stop =
reference: