Skip to content
Draft
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
5 changes: 4 additions & 1 deletion src/supervision/detection/tools/csv_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"class_id",
"confidence",
"tracker_id",
"area",
]


Expand All @@ -33,7 +34,7 @@ class CSVSink:
A utility class for saving detection data to a CSV file. This class is designed to
efficiently serialize detection objects into a CSV format, allowing for the
inclusion of bounding box coordinates and additional attributes like `confidence`,
`class_id`, and `tracker_id`.
`class_id`, `tracker_id`, and `area`.

!!! tip

Expand Down Expand Up @@ -117,6 +118,7 @@ def parse_detection_data(
detections: Detections, custom_data: dict[str, Any] | None = None
) -> list[dict[str, Any]]:
parsed_rows = []
areas = detections.area
for i in range(len(detections.xyxy)):
row = {
"x_min": detections.xyxy[i][0],
Expand All @@ -132,6 +134,7 @@ def parse_detection_data(
"tracker_id": ""
if detections.tracker_id is None
else str(detections.tracker_id[i]),
"area": str(areas[i]),
}

if hasattr(detections, "data"):
Expand Down
Loading