I\'m using opencv 2.4.2, python 2.7 The following simple code created a window of the correct name, but its content is just blank and doesn\'t show the image:
I had the same 215 error, which I was able to overcome by giving the full path to the image, as in, C:\Folder1\Folder2\filename.ext
For me waitKey() with number greater than 0 worked
cv2.waitKey(1)
I also had a -215 error. I thought imshow was the issue, but when I changed imread to read in a non-existent file I got no error there. So I put the image file in the working folder and added cv2.waitKey(0) and it worked.
If you are running inside a Python console, do this:
img = cv2.imread("yourimage.jpg")
cv2.imshow("img", img); cv2.waitKey(0); cv2.destroyAllWindows()
Then if you press Enter on the image, it will successfully close the image and you can proceed running other commands.
You've got all the necessary pieces somewhere in this thread:
if cv2.waitKey(): cv2.destroyAllWindows()
works fine for me in IDLE.
error: (-215) size.width>0 && size.height>0 in function imshow
This error is produced because the image is not found. So it's not an error of imshow function.