I am trying to do a simple area calculation of contours I get from findContours. My openCv version is 3.1.0
My code is:
cc = cv2.findContours(im_bw.c
Depending on the OpenCV version, cv2.findContours() has varying return signatures.
In OpenCV 3.4.X, cv2.findContours() returns 3 items
image, contours, hierarchy = cv.findContours(image, mode, method[, contours[, hierarchy[, offset]]])
In OpenCV 2.X and 4.1.X, cv2.findContours() returns 2 items
contours, hierarchy = cv.findContours(image, mode, method[, contours[, hierarchy[, offset]]])
You can easily obtain the contours regardless of the version like this:
cnts = cv2.findContours(image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]