def moment_score(contour): moments = cv2.moments(contour) hu = cv2.HuMoments(moments) # hu[6] should be close to 0 return 100 - (hu[6] * 100)