I am trying to run a simple program that reads an image from OpenCV. However, I am getting this error:
error: ......\\modules\\highgui\\src\\window.cpp:281:
This error occurs when you are trying to show an empty image. The image was probably not loaded correctly and could be due to a non-existent image, incorrect file path, or incorrect file extension when using cv2.imread(). You can check if the image was loaded properly by printing out its shape
image = cv2.imread('picture.png')
print(image.shape)
You will get something like this which returns a tuple of the number of rows, columns, and channels
(400, 391, 3)
If OpenCV was unable to load the image, it will throw this error when trying to print the shape
AttributeError: 'NoneType' object has no attribute 'shape'