1
votes

I am writing a face recognition code using opencv, and it returns an error at this line every time I run it.

This is the line of my code:

small_frame = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)

The error it throws:

cv2.error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/resize.cpp:3720: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

I think I could solve it if I can find this file named resize.cpp, but I don't know how to do it either.

1
I think you should provide size of the new image in place of None , check the link google.com/amp/s/www.tutorialkart.com/opencv/python/… , it is mandatory to provide new shape - manoj yadav
@manojyadav i have tried it using (0,0) but it is showing same error then also. - Satyam Goyal
Try (50,50) for just checking , (0,0) is not valida size I think - manoj yadav
Hello Satyam! Welcome to the community. I just edited your code a little bit in order to help avoiding any negative points to your question. - María Antignolo
Thank you @mantingablue for your help. - Satyam Goyal

1 Answers

2
votes

That error means that frame is empty. There is no image!

if (frame is None):
    print('!!! EMPTY IMAGE')
    sys.exit(0)

small_frame = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)