Issue
I intend to use opencv and pytesseract to extract text of out images. On executing the following code in a Python 3.7 Interpreter, I am receiving a error I'm not sure I understand.
import cv2
import pytesseract
#tesseract.exe location provided
pytesseract.tesseract_cmd=r'C:\\Users\\shree\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'
#image location provided
img=cv2.imread('C:\\Users\\shree\\Desktop\\hey.jpeg')
text=pytesseract.image_to_string(img)
print(text)
P.S:
- I have installed opencv and pytessearct in "C:\Users\shree\AppData\Local\Programs\Python\Python37-32\Scripts"
- Python 3.7 Interpreter is installed in "C:\Users\shree\AppData\Local\Programs\Python\Python37-32"
- Please excuse if this is an obvious/dumb question. Actually, I'm just starting out. I read about this at https://towardsdatascience.com/read-text-from-image-with-one-line-of-python-code-c22ede074cac
A Detailed answer and an alternate way(if required) would be highly appreciated. Thanks!
Solution
Replace the line,
pytesseract.tesseract_cmd=r'C:\\Users\\shree\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'
with,
pytesseract.pytesseract.tesseract_cmd = r'C:\\Users\\shree\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'
This should fix the issue if tesseract is installed properly.
Answered By - Amith Lakkakula
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.