Ask Your Question

Revision history [back]

cv2.error: assertion failed imshow

hey all,

I've been struggling for weeks on numerous forums trying to understand what I'm still guessing requires only a simple fix. I'm using python in ubuntu through a terminal. I've installed the opencv package without any issue. I've been following along with an online tutorial and the first example has me downloading a zip file from a repo on github. I extracted the zip and then have tried to simply read and display the image through inputting various commands within my cmd line. This is what I get:

"img = cv2.imread('lena.jpg', 0) print(img) None"

then I get this:

"Traceback (most recent call last): File "<stdin>", line 1, in <module> cv2.error: OpenCV(4.2.0) ../modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'"

Any ideas as to how I can troubleshoot this? Additionally I should also mention I tried using os.path.isfile and it returned "False" for the file in question. I also downloaded a random image from a google search and the same errors resulted. Is there another step that I haven't been shown that is required of me to setup how and where files/images are sent? I'm a newb to linux. Thanks for your help!

cv2.error: assertion failed imshow

hey all,

I've been struggling for weeks on numerous forums trying to understand what I'm still guessing requires only a simple fix. I'm using python in ubuntu through a terminal. I've installed the opencv package without any issue. I've been following along with an online tutorial and the first example has me downloading a zip file from a repo on github. I extracted the zip and then have tried to simply read and display the image through inputting various commands within my cmd line. This is what I get:

"img

img = cv2.imread('lena.jpg', 0)
print(img)
None"

None

then I get this:

"Traceback

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: OpenCV(4.2.0) ../modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'"

'imshow'

Any ideas as to how I can troubleshoot this? Additionally I should also mention I tried using os.path.isfile and it returned "False" for the file in question. I also downloaded a random image from a google search and the same errors resulted. Is there another step that I haven't been shown that is required of me to setup how and where files/images are sent? I'm a newb to linux. Thanks for your help!