1if cv2.getVersionMajor() in [2, 4]:
2 # OpenCV 2, OpenCV 4 case
3 contour, hier = cv2.findContours(
4 thresh.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)
5else:
6 # OpenCV 3 case
7 image, contour, hier = cv2.findContours(
8 thresh.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)