Ask Your Question

error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

asked 2020-01-05 12:43:26 -0500

kbrar gravatar image

updated 2020-01-08 09:08:08 -0500

supra56 gravatar image

I am running the below code and getting the error. Although, I changed the path of the image and gave absolute path as well, but things are not working. Kindly help!!

import cv2
import numpy as np 
image = cv2.imread("C:\\test_image.jpg")

    cv2.imshow('result', image)

edit retag flag offensive close merge delete


please ALWAYS CHECK like image==None after cv2.imread()

berak gravatar imageberak ( 2020-01-06 03:35:44 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2020-01-05 14:00:08 -0500

mvuori gravatar image

You should know that most languages don't like single backslashes, see

edit flag offensive delete link more


@mvuori when you edit question there is two backslashes. unfortunately it is not visble in the question without editing it

image description

LBerger gravatar imageLBerger ( 2020-01-05 14:04:29 -0500 )edit

hi i have same problem, i read image and i wanted to show this image with imshow command that pycharm gave this error suddenly:

cv2.imshow('image', cap)
cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build- 
j8nxabm_\opencv\modules\highgui\src\window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in 
function 'cv::imshow'

i have opencv-python and opencv-contrib-python please help me.

hoseinimage gravatar imagehoseinimage ( 2020-08-29 06:51:03 -0500 )edit

i have same problem

@hoseinimage then please DONT answer questions here ;(

and python noobs ALWAYS have the samee problem: they NEVER check, if their image was actually loaded (YOU HAVE TO !!!!), thus their progs fail later on invalid (None) images

berak gravatar imageberak ( 2020-08-29 08:04:51 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-01-05 12:43:26 -0500

Seen: 691 times

Last updated: Aug 29