Ask Your Question
0

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

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

kbrar gravatar image

updated 2020-01-08 09:08:08 -0600

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")

try:
    cv2.imshow('result', image)
    cv2.waitKey(0)

except:
    print("Here")
edit retag flag offensive close merge delete

Comments

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

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

1 answer

Sort by ยป oldest newest most voted
1

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

mvuori gravatar image

You should know that most languages don't like single backslashes, see https://lerner.co.il/2018/07/24/avoid...

edit flag offensive delete link more

Comments

@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 -0600 )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 4.4.0.42 please help me.

hoseinimage gravatar imagehoseinimage ( 2020-08-29 06:51:03 -0600 )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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 27,242 times

Last updated: Aug 29 '20