Skip to content

Commit

Permalink
Merge pull request #132 from biigle/rectangle-polygon-conversion
Browse files Browse the repository at this point in the history
Converts rectangles to polygon
  • Loading branch information
mzur authored Oct 7, 2024
2 parents 7333bce + 0021d67 commit 1363f5f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/resources/scripts/to_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def annotation(row):
circlePolygon = rotate(circlePolygon, angle, use_radians=True)
desired_array = numpy.array(
list(zip(*circlePolygon.exterior.coords.xy))).flatten().astype(float).tolist()
# convert Rectangle to Polygon
elif row.shape_name == "Rectangle":
# Rectangle only has 4 points as it does not close the polygon. Add the first point again so that it gets closed
desired_array.extend(desired_array[:2])

# x = even - start at the beginning at take every second item
x_coord = desired_array[::2]
Expand Down

0 comments on commit 1363f5f

Please sign in to comment.