Assertion failure : size.width>0 && size.height>0 in function imshow

The image fails to load (probably because you forgot the leading / in the path). imread then returns None. Passing None to imshow causes it to try to create a window of size 0x0, which fails.

The poor error handling in cv probably owes to its quite thin wrapper layer on the C++ implementation (where returning NULL on error is a common practice).


it's the path which is causing the problem, i had the same problem but when i gave the full path of the image it was working perfectly.


While using Raspbian in Rpi 3 I had the same problem when trying to read qrcodes. The error is because cv2 was not able to read the image. If using png image install pypng module.

sudo pip install pypng