在使用Python-opencv的时候,发生了这个问题,咱也是初学,不太懂,字面意思是『需要2个以上的值才能解压缩』,是不是不太理解何为解压哈,经过实践尝试是返回值多了
老版本的返回值写法:
image, contours, hierarchy = cv2.findContours(diff.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
opencv 4.2.0的写法:
contours, hierarchy = cv2.findContours(diff.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
即可;
如果你删除错返回值,例如image,contours = cv2.findContours(xxxx), 就会报:/Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/shapedescr.cpp:315: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'contourArea'