In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use Python and Tesseract to recognize pictures and text. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Installation
The installation of Linux and Mac platform is very simple. You can install it directly on the command line. By default, only English language packs are available, while Chinese language packs need to be specified.
Sudo apt-get install tesseract-ocr # ubuntu
Brew install tesseract # macOS
The Windows platform requires a binary installation package. The official download address is https://github.com/tesseract-ocr/tesseract/wiki/4.0-with-LSTM#400-alpha-for-windows. When installing, you need to select a Chinese language package to recognize Chinese characters.
Configuration
After the installation is completed, you need to set two environment variables $PATH and $TESSDATA_PREFIX. If you do not specify an error, add the installation path of tessertact to the PATH variable, and specify the value of the TESSDATA_PREFIX variable as the path of the language pack.
Actual combat
Python-tesseract is tessertact's Python package, which relies on the image processing library PIL (Pillow). After the environment is built, you can start customized development.
Below, I use du Fu's "climbing" as a demo to extract the text from it.
# pip install pytesseract install dependency package first
Try:
Import Image
Except ImportError:
From PIL import Image
Import pytesseract
# lang specifies simplified Chinese
Text = pytesseract.image_to_string (Image.open ('dufu-denggao1.jpeg'), lang='chi_sim')
Print (text)
Output result:
The wind is strong and the ape whistle is sad, and the gulls and herons on the white sand bank of Qingqing Hezhou fly back at low altitude. The fallen leaves are scattered one after another one after another, and the Yangtze River is surging and surging. As a guest in thousands of miles, I often wander everywhere. I have been sick all my life and have climbed the stage alone today. Times are difficult, life is difficult, often hate temples as white as frost, overpour Xinding muddy wine cup.
Thank you for reading! On "how to use Python and Tesseract to identify picture text" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 255
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.