I am starting out with OpenCV in Python, and I have the following simple code from a Youtube tutorial:
import numpy as np
import cv2
# read the image
img = cv2.imread('lion.jpg')
# show the image
# cv2.imshow has 2 parameters: the first is the name of the window in which we are showing the image
# and the second is the matrix referring to the image we want to show
cv2.imshow('image', img)
# We want the program to exit when the user presses a key
cv2.waitKey(0)
# Once the user presses the key, we want the program to shut down
cv2.destroyAllWindows()
However, I get the following error:
cv2.error: C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:331: error: (-215) size.width>0 && size.height>0 in function cv::imshow
The error occurred on the line where I call cv2.imshow().
Is this because there is no such image lion.jpg already included in the cv2 module? Because I tried using a random picture from my images folder instead and it threw the same error.