OpenCV(4.1.2) error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

Viewed 27568

I am recieving this error when running this line of code:

img = cv2.resize(img, (224,224)) 

OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:3720: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

2 Answers

Your img variable is empty, you probably didn't load the image correctly. Try printing your img.shape after you load your image. Then have a look at the path you specified, there is probably something wrong with it. (Either you misspelled something or the file doesn't exist in that directory)

frame = cv2.resize(frame,(224,224),fx=0,fy=0, interpolation = cv2.INTER_CUBIC)

I've changed my code to this and it works for me.

Related