fix: harden v1.2 trajectory disposal matching

This commit is contained in:
Yoilun
2026-05-29 16:26:15 +08:00
parent 90aa5dd704
commit 100b949f1f
11 changed files with 248 additions and 36 deletions

View File

@@ -474,7 +474,39 @@ class VisionTests(unittest.TestCase):
rejected.extend(diagnostics["rejected"])
self.assertEqual(all_evidence, [])
self.assertTrue(any(item["reason"] == "missing_source_motion" for item in rejected))
self.assertTrue(any(item["reason"] == "motion_started_outside_source" for item in rejected))
def test_motion_before_source_motion_cannot_seed_later_trash_evidence(self) -> None:
source = Region("source", ((0.05, 0.35), (0.25, 0.35), (0.25, 0.65), (0.05, 0.65)))
trash = Region("trash", ((0.72, 0.35), (0.95, 0.35), (0.95, 0.65), (0.72, 0.65)))
tracker = TrajectoryTracker(
[source],
trash,
RuntimeVisionSettings(trajectory_sample_interval_seconds=0.0, trajectory_min_points=3),
)
now = datetime(2026, 4, 28, 10, 0, tzinfo=timezone.utc)
tracker.observe(solid_frame(80, 80, 40), now, {"source": 1})
all_evidence = []
rejected = []
frames = [
frame_with_motion_patch(80, 80, (34, 36)),
frame_with_motion_patch(80, 80, (16, 36)),
frame_with_motion_patch(80, 80, (34, 36)),
frame_with_motion_patch(80, 80, (50, 36)),
frame_with_motion_patch(80, 80, (66, 36)),
]
for index, frame in enumerate(frames):
evidence, diagnostics = tracker.observe(
frame,
now + timedelta(seconds=index + 1),
{"source": 0},
)
all_evidence.extend(evidence)
rejected.extend(diagnostics["rejected"])
self.assertEqual(all_evidence, [])
self.assertTrue(any(item["reason"] == "motion_started_outside_source" for item in rejected))
def test_trajectory_diagnostics_include_per_candidate_events(self) -> None:
source = Region("source", ((0.05, 0.35), (0.25, 0.35), (0.25, 0.65), (0.05, 0.65)))