@@ -805,15 +805,15 @@ def test_line_zone_long_horizon_disappearing_detections(
805
805
[
806
806
# Frame 1: Both objects on right side
807
807
{
808
- "xyxy" : [[2 , 4 , 4 , 6 ], [6 , 4 , 8 , 6 ]],
809
- "tracker_id" : [1 , 2 ],
810
- "class_id" : [0 , 1 ]
808
+ "xyxy" : [[2 , 4 , 4 , 6 ], [6 , 4 , 8 , 6 ]],
809
+ "tracker_id" : [1 , 2 ],
810
+ "class_id" : [0 , 1 ],
811
811
},
812
812
# Frame 2: Both objects cross to left side
813
813
{
814
- "xyxy" : [[2 , - 6 , 4 , - 4 ], [6 , - 6 , 8 , - 4 ]],
815
- "tracker_id" : [1 , 2 ],
816
- "class_id" : [0 , 1 ]
814
+ "xyxy" : [[2 , - 6 , 4 , - 4 ], [6 , - 6 , 8 , - 4 ]],
815
+ "tracker_id" : [1 , 2 ],
816
+ "class_id" : [0 , 1 ],
817
817
},
818
818
],
819
819
[[False , False ], [True , True ]],
@@ -833,27 +833,25 @@ def test_line_zone_class_id_tracking(
833
833
) -> None :
834
834
"""Test that LineZone properly handles class_id changes during tracking."""
835
835
line_zone = LineZone (
836
- start = vector .start ,
837
- end = vector .end ,
838
- triggering_anchors = [Position .CENTER ]
836
+ start = vector .start , end = vector .end , triggering_anchors = [Position .CENTER ]
839
837
)
840
-
838
+
841
839
crossed_in_results = []
842
840
crossed_out_results = []
843
-
841
+
844
842
for frame in test_sequence :
845
843
detections = mock_detections (** frame )
846
844
crossed_in , crossed_out = line_zone .trigger (detections )
847
845
crossed_in_results .append (list (crossed_in ))
848
846
crossed_out_results .append (list (crossed_out ))
849
-
847
+
850
848
assert crossed_in_results == expected_crossed_in
851
849
assert crossed_out_results == expected_crossed_out
852
-
850
+
853
851
# Check per-class counts
854
852
for class_id , expected_count in expected_in_count_per_class .items ():
855
853
assert line_zone .in_count_per_class .get (class_id , 0 ) == expected_count
856
-
854
+
857
855
for class_id , expected_count in expected_out_count_per_class .items ():
858
856
assert line_zone .out_count_per_class .get (class_id , 0 ) == expected_count
859
857
@@ -888,16 +886,16 @@ def test_line_zone_class_id_with_minimum_threshold(
888
886
) -> None :
889
887
"""Test class_id changes work correctly with minimum crossing threshold."""
890
888
line_zone = LineZone (
891
- start = vector .start ,
889
+ start = vector .start ,
892
890
end = vector .end ,
893
891
triggering_anchors = [Position .CENTER ],
894
- minimum_crossing_threshold = minimum_crossing_threshold
892
+ minimum_crossing_threshold = minimum_crossing_threshold ,
895
893
)
896
-
894
+
897
895
for frame in test_sequence :
898
896
detections = mock_detections (** frame )
899
897
line_zone .trigger (detections )
900
-
898
+
901
899
# Check final counts
902
900
for class_id , expected_count in expected_final_counts .items ():
903
901
assert line_zone .in_count_per_class .get (class_id , 0 ) == expected_count
@@ -906,23 +904,21 @@ def test_line_zone_class_id_with_minimum_threshold(
906
904
def test_line_zone_class_id_none_handling () -> None :
907
905
"""Test LineZone handles None class_id values correctly."""
908
906
line_zone = LineZone (
909
- start = Point (0 , 0 ),
910
- end = Point (10 , 0 ),
911
- triggering_anchors = [Position .CENTER ]
907
+ start = Point (0 , 0 ), end = Point (10 , 0 ), triggering_anchors = [Position .CENTER ]
912
908
)
913
-
909
+
914
910
# Object with None class_id crosses the line
915
911
test_sequence = [
916
912
# Frame 1: Object on right side, no class_id
917
913
{"xyxy" : [[4 , 4 , 6 , 6 ]], "tracker_id" : [1 ], "class_id" : None },
918
914
# Frame 2: Object crosses to left side, still no class_id
919
915
{"xyxy" : [[4 , - 6 , 6 , - 4 ]], "tracker_id" : [1 ], "class_id" : None },
920
916
]
921
-
917
+
922
918
for frame in test_sequence :
923
919
detections = mock_detections (** frame )
924
920
line_zone .trigger (detections )
925
-
921
+
926
922
# Should work with None class_id
927
923
assert line_zone .in_count_per_class [None ] == 1
928
- assert line_zone .in_count == 1
924
+ assert line_zone .in_count == 1
0 commit comments