Hi I am trying to read in and display a picture with cv2 for further analysis with the following code:
Edit: I added the path with my username being clear to prove it doesn't contain wacky characters. I also tried with multiple .jpg files. I am using opencv-python version 4.9.0.80
import cv2
path = r'C:\Users\Max\Documents\Pictures\pandas_secondary.jpg'
image = cv2.imread(path)
window_name = 'image'
cv2.imshow(window_name, image)
cv2.waitKey(0)
cv2.destroyAllWindows()
However, this gives me the following error:
error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:971: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
The path to my image is correct in my first posted Question I only anonymized it for the question. Now I added the actual path. what am I doing wrong here?
Update: moving the picture to the same directory as my python code leads to the code running for ever, even if the picture is only 20 kb sized. Displaying the picture with pillow works fine though. I also reinstalled cv2 by:
pip install --upgrade --force-reinstall opencv-python
which didn't solve the problem.
This is the picture:
os.path.isfile(path)
returns false.
os.path.isfile()