I was following a tutorial to build a facial recognition software:
small_frame = cv2.resize(frame, (0,0), fx=0.25,fy=0.25),
rgb_small_frame = small_frame[:,:,::-1]
when this error showed up:
cv2.error: OpenCV(4.6.0) /Users/xperience/actions-runner/_work/opencv-python/opencv-python/opencv/modules/imgproc/src/resize.cpp:4052: error: (-215:Assertion failed) !ssize.empty() in function 'resize'
CodePudding user response:
This problem was few times on Stackoverflow.
When cv2
can't get frame
from file or webcam then it doesn't raise error but it return status False
, and frame None
and you should check one of this values before you run rest of code
ret, frame = cap.read()
if ret: # if ret is True:
small_frame = cv2.resize(frame, (0,0), fx=0.25,fy=0.25)
# ... rest of code ...
or
ret, frame = cap.read()
if frame is not None: # it can't be `if not frameret is True:`
small_frame = cv2.resize(frame, (0,0), fx=0.25,fy=0.25)
# ... rest of code ...