This content originally appeared on DEV Community and was authored by M.V.S.Sai hiranmayee
Using Tesseract library, we can detect the text from an image in 3 lines of code.
Step-1:
Install teserract library
In command prompt: pip install pytesseract
In Anaconda prompt: conda install -c conda-forge pytesseract
Step-2:
Download and install the Tesseract OCR executable from the following links
https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w32-setup-v5.0.0-alpha.20210506.exe (32-bit)
https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v5.0.0-alpha.20210506.exe (64-bit)
Step-3:
And run the below given code to extract text from an image
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract'
print(pytesseract.image_to_string(r'link to the image from which the text to be detected'))
This content originally appeared on DEV Community and was authored by M.V.S.Sai hiranmayee
M.V.S.Sai hiranmayee | Sciencx (2021-11-28T13:54:37+00:00) 3-lines code to detect text from an image in python. Retrieved from https://www.scien.cx/2021/11/28/3-lines-code-to-detect-text-from-an-image-in-python/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.