diff --git a/darwin/exporter/formats/yolo_segmented.py b/darwin/exporter/formats/yolo_segmented.py index cab355ec1..dae3b0f5d 100644 --- a/darwin/exporter/formats/yolo_segmented.py +++ b/darwin/exporter/formats/yolo_segmented.py @@ -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"], ) diff --git a/tests/darwin/exporter/formats/export_yolo_segmented_test.py b/tests/darwin/exporter/formats/export_yolo_segmented_test.py index a685dd76a..94aba2ca0 100644 --- a/tests/darwin/exporter/formats/export_yolo_segmented_test.py +++ b/tests/darwin/exporter/formats/export_yolo_segmented_test.py @@ -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"