Problem in loading the image.. [closed]
import numpy as np import cv2
img = cv2.imread("mud.jpeg",cv2.IMREAD_COLOR)
cv2.imshow("bhatnagar",img) cv2.waitKey(5)
This is the error I am getting: I have even tried by giving the path of the image which could also be done if in case the file is not in the working directory.
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, file C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp, line 325
cv2.imshow("bhatnagar",img) cv2.error: C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:325: error: (-215) size.width>0 && size.height>0 in function cv::imshow
it did not find the image, or it is not a jpg, but a mislabelled gif.
anyway, you have to check
if image!=None:
before proceeding with imshow() or the like.Thanks a lot..done...
what if i am reading from the webcam?
@lucifer97, the problem is simply, that python ppl NEVER check the outcome of
imread()
orcap.read()
so, if something goes wrong there, it errors in the NEXT line, because of an invalid image.so, same for the webcam: CHECK !