Skip to content

Commit

Permalink
Converts rectangles to polygon
Browse files Browse the repository at this point in the history
In order to be correctly classified as polygon and not as a line, a rectangle should be identified by 5 points as the first point should be added at the end of the point array
  • Loading branch information
dbrembilla committed Oct 4, 2024
1 parent 7333bce commit 0021d67
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 0021d67

Please sign in to comment.