Skip to content

Commit

Permalink
fix calibration_model/fld.py (#132)
Browse files Browse the repository at this point in the history
* fix calibration_model/fld.py

* Update fld.py

* Update fld.py
  • Loading branch information
shunsuke-iwashita authored Nov 1, 2023
1 parent a3aa135 commit 21df873
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sportslabkit/calibration_model/fld.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def _get_largest_contour(self, image):
def _approximate_hull(self, contour):
hull = cv2.convexHull(contour)
return hull

def _get_upper_left_courner(self, hull):
"""Find the nearest point from the upper left corner."""
sorted_hull = sorted(hull, key=lambda x:x[0][0]*x[0][0] + x[0][1]*x[0][1])
return sorted_hull[0][0]

def _farthest_point_from(self, reference_point, point_list):
"""Find the point in 'point_list' that is farthest from 'reference_point'."""
Expand All @@ -66,7 +71,7 @@ def _farthest_point_from(self, reference_point, point_list):

def _approximate_quad(self, hull):
"""Approximate a convex hull to a quadrilateral by considering most distant points."""
first_point = hull[0][0]
first_point = self._get_upper_left_corner(hull)
second_point = self._farthest_point_from(first_point, hull)

max_distance = 0
Expand Down

0 comments on commit 21df873

Please sign in to comment.