I am trying to recognize text from an image to then have the text outputted; however, this error spits out:
Traceback (most recent call last):
if path and image name is verified and correct then just close the jupyter notebook (or whatever platform you are using) and restart it. It worked for me.
This means you are passing a Uninitialized variable to
> cv2.cvtColor()
After this statement:
# Read image with opencv
img = cv2.imread(img_path)
Can you try to print the img variable before passing to cv2.cvtColor() function
> print(img) or print(img.shape)
to make sure function call to read the image is successful
This error occurs when the image is in one format and in the python program you specify other format.
Example:
File Path= /home/user/image.jpg
but in the python program you read the image as jpeg
img = cv.imread("image.jpeg")
Then you will be facing this error
I think your source path should be:
src_path = "C:/Users/Benji's Beast/Desktop/"
Because in here get_string(src_path + "cont.jpg") you've concatenated the image name.
The problems are this one
src_path = "C:/Users/Benji's Beast/Desktop/image.PNG"
and this one
print(get_string(src_path + "cont.jpg") )
You are appending the image input file name from image.PNG to image.PNG.cont.jpg
If your input image filename is cont.jpg and it is located on your Desktop, then try to replace your code with :
src_path = "C:\Users\Benji's Beast\Desktop\"
and
print(get_string(src_path + "cont.jpg") )