The error message suggests that the function cv2.findContours() is returning only 2 values instead of the expected 3 values.

In older versions of OpenCV, the function cv2.findContours() returned three values: contours, hierarchy, and image. However, in newer versions of OpenCV, the function returns only contours and hierarchy.

To fix this error, you can modify the code to only accept two values:

contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

If you are using an older version of OpenCV and need the third value (image), you can update your OpenCV version or refer to the documentation of your specific version to find an alternative solution

_contourshierarchy = cv2findContoursthresh1cv2RETR_LISTcv2CHAIN_APPROX_SIMPLEValueError not enough values to unpack expected 3 got 2

原文地址: https://www.cveoy.top/t/topic/iuie 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录