Skip to content

Commit

Permalink
Adaptively approximate the circle shape (wkentaro#945)
Browse files Browse the repository at this point in the history
* daptively approximate the circle shape

* Black

Co-authored-by: Joshua <[email protected]>
Co-authored-by: Kentaro Wada <[email protected]>
  • Loading branch information
3 people authored Nov 11, 2021
1 parent f696ea7 commit a792351
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/instance_segmentation/labelme2coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def main():
if shape_type == "circle":
(x1, y1), (x2, y2) = points
r = np.linalg.norm([x2 - x1, y2 - y1])
n_points_circle = 12
# r(1-cos(a/2))<x, a=2*pi/N => N>pi/arccos(1-x/r)
# x: tolerance of the gap between the arc and the line segment
n_points_circle = max(int(np.pi / np.arccos(1 - 1 / r)), 12)
i = np.arange(n_points_circle)
x = x1 + r * np.sin(2 * np.pi / n_points_circle * i)
y = y1 + r * np.cos(2 * np.pi / n_points_circle * i)
Expand Down

0 comments on commit a792351

Please sign in to comment.