Skip to content

Commit

Permalink
Add support circle shap_type on label2coco.py (wkentaro#804)
Browse files Browse the repository at this point in the history
* Add support circle shap_type on label2coco.py

* Fix style

Co-authored-by: Kentaro Wada <[email protected]>
  • Loading branch information
firesh and wkentaro authored Oct 25, 2021
1 parent 75d085e commit 975fe11
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/instance_segmentation/labelme2coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ def main():
x1, x2 = sorted([x1, x2])
y1, y2 = sorted([y1, y2])
points = [x1, y1, x2, y1, x2, y2, x1, y2]
if shape_type == "circle":
(x1, y1), (x2, y2) = points
r = np.linalg.norm([x2 - x1, y2 - y1])
n_points_circle = 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)
points = np.stack((x, y), axis=1).flatten().tolist()
else:
points = np.asarray(points).flatten().tolist()

Expand Down

0 comments on commit 975fe11

Please sign in to comment.