feat: multi-model modes (A/B/C/D, default B) + box counting + manual-mode banner
ci / smoke (push) Canceled after 0s
ci / smoke (push) Canceled after 0s
This commit is contained in:
1 parent
52d3127302
commit
6e4af50646
14 files changed
+819
-128
No files matched your search
+42
-4
@@ -1,15 +1,15 @@
|
||||
"""Smoke tests for LineCrossCounter (src/counting.py). Pure-Python: needs only numpy."""
|
||||
"""Smoke tests for LineCrossCounter + MultiClassLineCounter (src/counting.py). Pure-Python: needs only numpy."""
|
||||
|
||||
from src.counting import LineCrossCounter
|
||||
from src.counting import LineCrossCounter, MultiClassLineCounter
|
||||
from src.interfaces import Detection
|
||||
|
||||
|
||||
def _det(tid, y1, cx=500.0):
|
||||
def _det(tid, y1, cx=500.0, class_name="sack"):
|
||||
return Detection(
|
||||
bbox=(cx - 20, y1, cx + 20, y1 + 60),
|
||||
confidence=0.9,
|
||||
class_id=0,
|
||||
class_name="sack",
|
||||
class_name=class_name,
|
||||
track_id=tid,
|
||||
)
|
||||
|
||||
@@ -58,3 +58,41 @@ def test_net_and_reset():
|
||||
assert c.net_count == 1
|
||||
c.reset()
|
||||
assert (c.loading_count, c.unloading_count, c.net_count) == (0, 0, 0)
|
||||
|
||||
|
||||
def _mcounter():
|
||||
return MultiClassLineCounter(line_y=100, line_x_start=0, line_x_end=1000, margin=20)
|
||||
|
||||
|
||||
def test_multiclass_sack_and_box_independent():
|
||||
c = _mcounter()
|
||||
c.update([_det(1, y1=10, class_name="sack"), _det(7, y1=10, class_name="box")])
|
||||
events = c.update([_det(1, y1=150, class_name="sack"), _det(7, y1=150, class_name="box")])
|
||||
assert len(events) == 2 # flat list, callsites unaffected
|
||||
assert {e["class_name"] for e in events} == {"sack", "box"}
|
||||
assert c.loading_count == 1
|
||||
assert c.box_loading_count == 1
|
||||
assert c.unloading_count == 0 and c.box_unloading_count == 0
|
||||
|
||||
|
||||
def test_multiclass_shared_track_id_no_collision():
|
||||
# sack track 9 and box track 9 are different objects; both must count
|
||||
c = _mcounter()
|
||||
c.update([_det(9, y1=10, class_name="sack"), _det(9, y1=10, class_name="box")])
|
||||
c.update([_det(9, y1=150, class_name="sack"), _det(9, y1=150, class_name="box")])
|
||||
assert c.loading_count == 1
|
||||
assert c.box_loading_count == 1
|
||||
|
||||
|
||||
def test_multiclass_geometry_sync_and_reset():
|
||||
c = _mcounter()
|
||||
c.line_y = 200
|
||||
assert c._sack.line_y == 200 and c._box.line_y == 200
|
||||
c.line_x_start = 10
|
||||
c.line_x_end = 900
|
||||
assert (c._sack.line_x_start, c._box.line_x_end) == (10, 900)
|
||||
c.update([_det(1, y1=100, class_name="sack")])
|
||||
c.update([_det(1, y1=250, class_name="sack")])
|
||||
assert c.loading_count == 1
|
||||
c.reset()
|
||||
assert (c.loading_count, c.box_loading_count, c.box_net_count) == (0, 0, 0)
|
||||
Reference in new issue
Block a user