def get_approx_contour(contour, tol=.01): """Get rid of 'useless' points in the contour""" epsilon = tol * cv2.arcLength(contour, True) return cv2.approxPolyDP(contour, epsilon, True)