fix: seed trajectories from recent source motion
This commit is contained in:
@@ -417,6 +417,36 @@ class VisionTests(unittest.TestCase):
|
||||
self.assertEqual(trash_diagnostics["emitted"][0]["reason"], "emitted")
|
||||
self.assertTrue(trash_diagnostics["emitted"][0]["segmented"])
|
||||
|
||||
def test_recent_source_motion_seeds_track_when_empty_confirmation_lags(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,
|
||||
trajectory_min_confidence=0.72,
|
||||
trajectory_motion_delta=20.0,
|
||||
trajectory_min_blob_area=12,
|
||||
),
|
||||
)
|
||||
now = datetime(2026, 6, 1, 11, 25, tzinfo=timezone.utc)
|
||||
|
||||
tracker.observe(frame_with_motion_patch(80, 80, (8, 36)), now, {"source": 1})
|
||||
tracker.observe(frame_with_motion_patch(80, 80, (16, 36)), now + timedelta(seconds=1), {"source": 1})
|
||||
evidence, diagnostics = tracker.observe(
|
||||
frame_with_motion_patch(80, 80, (66, 36)),
|
||||
now + timedelta(seconds=2),
|
||||
{"source": 0},
|
||||
)
|
||||
|
||||
self.assertEqual(len(evidence), 1)
|
||||
self.assertEqual(evidence[0].source_zone_id, "source")
|
||||
self.assertEqual(len(evidence[0].track_points), 2)
|
||||
self.assertTrue(diagnostics["emitted"][0]["segmented"])
|
||||
self.assertTrue(diagnostics["emitted"][0]["source_seeded"])
|
||||
|
||||
def test_motion_that_starts_away_from_source_zone_is_rejected(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)))
|
||||
|
||||
Reference in New Issue
Block a user