diff --git a/supervision/detection/line_zone.py b/supervision/detection/line_zone.py index 5f393d88..b63660bc 100644 --- a/supervision/detection/line_zone.py +++ b/supervision/detection/line_zone.py @@ -79,7 +79,7 @@ class LineZone: Position.BOTTOM_LEFT, Position.BOTTOM_RIGHT, ), - crossing_acceptance_threshold: int = 1, + minimum_crossing_threshold: int = 1, ): """ Args: @@ -90,7 +90,7 @@ class LineZone: to consider when deciding on whether the detection has passed the line counter or not. By default, this contains the four corners of the detection's bounding box - crossing_acceptance_threshold (int): Detection needs to be seen + minimum_crossing_threshold (int): Detection needs to be seen on the other side of the line for this many frames to be considered as having crossed the line. This is useful when dealing with unstable bounding boxes or when detections @@ -98,7 +98,7 @@ class LineZone: """ self.vector = Vector(start=start, end=end) self.limits = self._calculate_region_of_interest_limits(vector=self.vector) - self.crossing_history_length = max(2, crossing_acceptance_threshold + 1) + self.crossing_history_length = max(2, minimum_crossing_threshold + 1) self.crossing_state_history: Dict[int, Deque[bool]] = defaultdict( lambda: deque(maxlen=self.crossing_history_length) ) diff --git a/test/detection/test_line_counter.py b/test/detection/test_line_counter.py index d0ec5fbd..a140add5 100644 --- a/test/detection/test_line_counter.py +++ b/test/detection/test_line_counter.py @@ -493,7 +493,7 @@ def test_line_zone_multiple_detections( @pytest.mark.parametrize( - "vector, xyxy_sequence, triggering_anchors, crossing_acceptance_threshold, " + "vector, xyxy_sequence, triggering_anchors, minimum_crossing_threshold, " "expected_crossed_in, expected_crossed_out", [ ( # Detection lingers around line, all crosses counted @@ -578,7 +578,7 @@ def test_line_zone_one_detection_long_horizon( vector: Vector, xyxy_sequence: List[List[float]], triggering_anchors: List[Position], - crossing_acceptance_threshold: int, + minimum_crossing_threshold: int, expected_crossed_in: List[bool], expected_crossed_out: List[bool], ) -> None: @@ -586,7 +586,7 @@ def test_line_zone_one_detection_long_horizon( start=vector.start, end=vector.end, triggering_anchors=triggering_anchors, - crossing_acceptance_threshold=crossing_acceptance_threshold, + minimum_crossing_threshold=minimum_crossing_threshold, ) crossed_in_list = [] @@ -609,7 +609,7 @@ def test_line_zone_one_detection_long_horizon( @pytest.mark.parametrize( - "vector, xyxy_sequence, anchors, crossing_acceptance_threshold, " + "vector, xyxy_sequence, anchors, minimum_crossing_threshold, " "expected_crossed_in, expected_crossed_out, expected_count_in, " "expected_count_out, exception", [ @@ -743,7 +743,7 @@ def test_line_zone_long_horizon_disappearing_detections( vector: Vector, xyxy_sequence: List[List[Optional[List[float]]]], anchors: List[Position], - crossing_acceptance_threshold: int, + minimum_crossing_threshold: int, expected_crossed_in: List[List[bool]], expected_crossed_out: List[List[bool]], expected_count_in: List[int], @@ -755,7 +755,7 @@ def test_line_zone_long_horizon_disappearing_detections( start=vector.start, end=vector.end, triggering_anchors=anchors, - crossing_acceptance_threshold=crossing_acceptance_threshold, + minimum_crossing_threshold=minimum_crossing_threshold, ) crossed_in_list = [] crossed_out_list = []