Converting image to grayscale

asked 2020-12-01 21:13:26 -0500

hi a newbie in python and opencv here.i tried to convert a picture from coloured to grayscale but it has an error,eventhou i take that code from youtube and all of my friends tried it and it work.i don't know what went wrong here is the error :

cv2.imshow('Original',image)

cv2.error: OpenCV(4.4.0) D:\Build\OpenCV\opencv-4.4.0\modules\highgui\src\window.cpp:384: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

can any of you guys help me solving this problem.i'm using python 3.9.0 and opencv_python-4.4.0-cp39-cp39-win_amd64.whl i believe both are the latest version.

edit retag flag offensive close merge delete

Comments

1

post all relevant code. speculate on what the error message could mean (read it).

crackwitz gravatar imagecrackwitz ( 2020-12-02 01:25:04 -0500 )edit
1

error means, your image is empty / invalid. opencv does not throw exceptions with imread() or Videocapture.read() failures, which is terribly confusing for python noobs

please add checks there, before further trying to process images

berak gravatar imageberak ( 2020-12-02 04:49:27 -0500 )edit