An alternative to work with 2.x 、3.x、4.x is:
cnts, hiers = cv2.findContours(...)[-2:]
Notice:
cv2.findContourshas changed since
OpenCV 3.x, but in
OpenCV 4.0it
changes back!!!
In OpenCV 3.4:
findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy
In OpenCV 4.0:
findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy



