ValueError: not enough values to unpack (expected 3, got 2)

我在使用cv2.findContours函数中遇到以上错误,经查询找到该错误原因:

在 OpenCV 4.X 中,函数 cv2.findContours()仅有两个返回值,

其语法格式为:

contours, hierarchy = cv2.findContours( image, mode, method)

若不想使用此语法,请将opencv更换至3.X版本!