OpenCV(4.5.4-dev) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\resize.cpp:4051: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
This error arises if you aren't giving the right path to the image,
check extentions(.png, .jpg)
if you are working on jupyter notebook on the folder C:/users/user
and your desired image called Dog.png exists in C:/users/user/Folder
use this -
Image = cv2.imread("Folder/Dog.png",-1)
opencv(4.1.2) /io/opencv/modules/imgproc/src/resize.cpp:3720: error: (-215:assertion failed) !ssize.empty() in function 'resize'
Generally this problem occurs due to resizing of the image, I just apply try and catch statement for resizing the image so that any error handling. It is working fine and not getting error related to shape.
img=cv2.imread(filename)
print(img)
try:
img = cv2.resize(img, (1400, 1000), interpolation=cv2.INTER_AREA)
print(img.shape)
except:
break
height, width , layers = img.shape
size=(width,height)
print(size)
|