cv2.error: assertion failed imshow [closed]

asked 2020-08-03 13:36:54 -0600

updated 2020-08-05 22:14:11 -0600

supra56 gravatar image

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!

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by berak
close date 2020-08-03 14:38:11.332422

Comments

this has been asked and answered a million times before.

(your image never loaded, you never checked, that's why you're dealing with None all the way down.)

berak gravatar imageberak ( 2020-08-03 14:38:04 -0600 )edit