error: (-215) size.width>0 && size.height>0 in function imshow
1 img2 = cv2.rectangle(frame, (x,y), (x+w,y+h), 255,2) 2 cv2.imshow(‘img2‘,img2)
调试时可发现img2的类型为NoneType.即img2为empty
改为如下
1 cv2.rectangle(frame, (x,y), (x+w,y+h), 255,2) 2 3 cv2.imshow(‘img2‘,frame)
时间: 2024-10-10 16:18:06