3-lines code to detect text from an image in python

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…


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'))

Image description


This content originally appeared on DEV Community and was authored by M.V.S.Sai hiranmayee


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » 3-lines code to detect text from an image in python." M.V.S.Sai hiranmayee | Sciencx - Sunday November 28, 2021, https://www.scien.cx/2021/11/28/3-lines-code-to-detect-text-from-an-image-in-python/
HARVARD
M.V.S.Sai hiranmayee | Sciencx Sunday November 28, 2021 » 3-lines code to detect text from an image in python., viewed ,<https://www.scien.cx/2021/11/28/3-lines-code-to-detect-text-from-an-image-in-python/>
VANCOUVER
M.V.S.Sai hiranmayee | Sciencx - » 3-lines code to detect text from an image in python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/28/3-lines-code-to-detect-text-from-an-image-in-python/
CHICAGO
" » 3-lines code to detect text from an image in python." M.V.S.Sai hiranmayee | Sciencx - Accessed . https://www.scien.cx/2021/11/28/3-lines-code-to-detect-text-from-an-image-in-python/
IEEE
" » 3-lines code to detect text from an image in python." M.V.S.Sai hiranmayee | Sciencx [Online]. Available: https://www.scien.cx/2021/11/28/3-lines-code-to-detect-text-from-an-image-in-python/. [Accessed: ]
rf:citation
» 3-lines code to detect text from an image in python | M.V.S.Sai hiranmayee | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.