diff --git a/supervision/detection/line_zone.py b/supervision/detection/line_zone.py index 45bc9644..4198135d 100644 --- a/supervision/detection/line_zone.py +++ b/supervision/detection/line_zone.py @@ -167,20 +167,19 @@ class LineZone: # Calculate which anchors lie to the left of the line triggers = self._cross_product(all_anchors, self.vector) < 0 - # Reduce to find out if all anchors for a - # detection lie to the left (or right) of the line - max_triggers = np.max(triggers, axis=0) - min_triggers = np.min(triggers, axis=0) + has_any_left_trigger = np.any(triggers, axis=0) + has_any_right_trigger = np.any(~triggers, axis=0) + is_uniformly_triggered = ~(has_any_left_trigger & has_any_right_trigger) for i, tracker_id in enumerate(detections.tracker_id): if not in_limits[i]: continue - if min_triggers[i] != max_triggers[i]: + if not is_uniformly_triggered[i]: # One anchor lies to the left of the line # whilst another lies to the right continue - tracker_state = max_triggers[i] + tracker_state = has_any_left_trigger[i] if tracker_id not in self.tracker_state: self.tracker_state[tracker_id] = tracker_state continue