From 40b537c0bebe535e93ed7b7eef719c3a2a2e57e0 Mon Sep 17 00:00:00 2001 From: Linas Kondrackis Date: Tue, 21 May 2024 13:58:20 +0300 Subject: [PATCH] tracker_id contents are never None --- supervision/detection/line_zone.py | 10 +++++++--- supervision/detection/tools/smoother.py | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/supervision/detection/line_zone.py b/supervision/detection/line_zone.py index 53d762a0..fe850894 100644 --- a/supervision/detection/line_zone.py +++ b/supervision/detection/line_zone.py @@ -140,6 +140,13 @@ class LineZone: if len(detections) == 0: return crossed_in, crossed_out + if detections.tracker_id is None: + print( + "Line zone conting skipped. LineZone requires tracker_id. Refer to " + "https://supervision.roboflow.com/latest/trackers for more information." + ) + return crossed_in, crossed_out + all_anchors = np.array( [ detections.get_anchors_coordinates(anchor) @@ -148,9 +155,6 @@ class LineZone: ) for i, tracker_id in enumerate(detections.tracker_id): - if tracker_id is None: - continue - box_anchors = [Point(x=x, y=y) for x, y in all_anchors[:, i, :]] in_limits = all( diff --git a/supervision/detection/tools/smoother.py b/supervision/detection/tools/smoother.py index f58f3299..6b20bdd1 100644 --- a/supervision/detection/tools/smoother.py +++ b/supervision/detection/tools/smoother.py @@ -78,8 +78,6 @@ class DetectionsSmoother: for detection_idx in range(len(detections)): tracker_id = detections.tracker_id[detection_idx] - if tracker_id is None: - continue self.tracks[tracker_id].append(detections[detection_idx])