Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions darwin/exporter/formats/yolo_segmented.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,19 @@ def _handle_bounding_box(data: dict, im_w: int, im_h: int, annotation_index: int
try:
# Create 8 coordinates for the x,y pairs of the 4 corners
x1, y1, x2, y2, x3, y3, x4, y4, x5, y5 = (
# top left corner
data["x"],
data["y"],
# top right corner
(data["x"] + data["w"]),
(data["y"] + data["h"]),
(data["y"]),
# bottom right
(data["x"] + data["w"]),
data["y"],
(data["y"] + data["h"]),
# bottom left
data["x"],
(data["y"] + data["h"]),
# top left again to close the polygon
data["x"],
data["y"],
)
Expand Down
4 changes: 2 additions & 2 deletions tests/darwin/exporter/formats/export_yolo_segmented_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def test_export_yolo_segmented(annotation_files: List[AnnotationFile], tmp_path:

output_lines = (tmp_path / "file1.txt").read_text().splitlines()
if CLOSE_VERTICES:
assert output_lines[0] == "0 0.02 0.03 0.27 0.16 0.27 0.03 0.02 0.16 0.02 0.03"
assert output_lines[0] == "0 0.02 0.03 0.27 0.03 0.27 0.16 0.02 0.16 0.02 0.03"
assert output_lines[1] == "1 0.0 0.0 0.0 0.1 0.05 0.15 0.1 0.1 0.0 0.1 0.0 0.0 0.0 0.0"
else:
assert output_lines[0] == "0 0.02 0.03 0.27 0.16 0.27 0.03 0.02 0.16"
assert output_lines[0] == "0 0.02 0.03 0.27 0.03 0.27 0.16 0.02 0.16"
assert output_lines[1] == "1 0.0 0.0 0.0 0.1 0.05 0.15 0.1 0.1 0.0 0.1 0.0 0.0"