diff --git a/edge/detectors/ghost.py b/edge/detectors/ghost.py index fb45b0e..1612227 100644 --- a/edge/detectors/ghost.py +++ b/edge/detectors/ghost.py @@ -42,7 +42,7 @@ class GhostIncidentDetector: out = [] for tid, (spatial, state, _height, lost_at) in list(self._candidates.items()): if now - lost_at >= self.cfg.reappear_s: - out.append({"spatial": spatial, "last_state": state, + out.append({"track_id": tid, "spatial": spatial, "last_state": state, "waited_s": round(now - lost_at, 1)}) self._candidates.pop(tid, None) return out diff --git a/edge/engine.py b/edge/engine.py index bea72a4..b469a70 100644 --- a/edge/engine.py +++ b/edge/engine.py @@ -67,9 +67,10 @@ class EventEngine: events.append(self._mk(etype, now, tr.track_id, zone_id=hit["zone_id"])) for g in self.ghost.update(active_tracks, now): - key = (EventType.GHOST, round(g["spatial"][0]), round(g["spatial"][1])) + key = (EventType.GHOST, g["track_id"]) if self._allow(key, now): - events.append(self._mk(EventType.GHOST, now, spatial=g["spatial"], + events.append(self._mk(EventType.GHOST, now, track_id=g["track_id"], + spatial=g["spatial"], metrics={"last_state": g["last_state"], "waited_s": g["waited_s"]})) return events diff --git a/tests/test_ghost.py b/tests/test_ghost.py index 550a665..07eb39f 100644 --- a/tests/test_ghost.py +++ b/tests/test_ghost.py @@ -16,6 +16,7 @@ def test_lost_dangerous_track_becomes_ghost_after_wait(): assert len(ghosts) == 1 assert ghosts[0]["last_state"] == "FALLEN" assert ghosts[0]["spatial"] == (110.0, 130.0) # bbox 중심 + assert ghosts[0]["track_id"] == 1 def test_non_dangerous_lost_track_is_ignored(): d = GhostIncidentDetector(GhostConfig(reappear_s=1.0))