feat(tracking): add recursive lifecycle updates and quality diagnostics

Implement the next tracker tranche around a recursive articulated state rather than per-frame ad hoc updates.

Track state now propagates full pose/velocity/shape covariance, uses process noise during prediction, and drives active-to-lost transitions from both miss counts and recursive score thresholds. The multiview update path replaces the generic SciPy least_squares call with a bounded LM/GN loop that returns parameter and beta covariance blocks, accepted-joint counts, mean reprojection error, and iteration diagnostics.

Lost-track handling is stricter and safer: proposal-based reacquisition now requires same-frame 2D support and articulated refinement before a track can return to active. Proposal clusters retain contributing detection indices, the tracker searches broadly within contributing views, and proposal-compatible lost frames are surfaced explicitly instead of silently reviving a track. Old scene JSONs with imgpaths now default to the RPT camera-pose convention so proposal reprojection gating works on the sample scenes.

Add ActualTest support diagnostics that summarize event counts, accepted support, reprojection quality, and tracker diagnostics, plus focused regressions for camera conventions, score-driven demotion, covariance behavior, proposal-compatible lost handling, and broader proposal-backed matching.
This commit is contained in:
2026-03-27 15:36:48 +08:00
parent 8085885a3a
commit 0bfeec77e4
10 changed files with 1883 additions and 257 deletions
+62 -1
View File
@@ -5,7 +5,13 @@ import pyarrow as pa
import pyarrow.parquet as pq
from pose_tracking_exp.common.joints import BODY20_INDEX_BY_NAME
from tests.support.actual_test import load_actual_test_scene, load_actual_test_segment_bundles
from pose_tracking_exp.schema import TrackUpdateEvent, TrackerDiagnostics, TrackedFrameResult
from tests.support.actual_test import (
format_frame_summary_lines,
load_actual_test_scene,
load_actual_test_segment_bundles,
summarize_tracking_results,
)
def _write_parquet(path: Path, rows: list[dict[str, object]]) -> None:
@@ -125,3 +131,58 @@ def test_load_actual_test_keeps_partial_camera_frames(tmp_path: Path) -> None:
assert [view.camera_name for view in bundles[1].views] == ["5602", "5603"]
assert len(bundles[1].views[0].detections) == 1
assert bundles[1].views[1].detections == ()
def test_actual_test_summary_reports_event_counts() -> None:
results = [
TrackedFrameResult(
bundle_index=0,
timestamp_unix_ns=0,
tentative_tracks=(),
active_tracks=(),
lost_tracks=(),
proposals=(),
update_events=(
TrackUpdateEvent(
track_id=1,
action="direct_update",
accepted_view_count=2,
accepted_joint_count=14,
mean_reprojection_error=6.0,
),
),
),
TrackedFrameResult(
bundle_index=1,
timestamp_unix_ns=1,
tentative_tracks=(),
active_tracks=(),
lost_tracks=(),
proposals=(),
update_events=(
TrackUpdateEvent(track_id=1, action="predict_only"),
TrackUpdateEvent(
track_id=1,
action="proposal_compatible",
proposal_view_count=2,
proposal_support_size=3,
mean_reprojection_error=12.0,
),
),
),
]
summary = summarize_tracking_results(
results,
TrackerDiagnostics(promotions=1, proposal_compatible_lost_frames=1),
)
lines = format_frame_summary_lines(results)
assert summary.bundle_count == 2
assert summary.update_action_counts["direct_update"] == 1
assert summary.update_action_counts["proposal_compatible"] == 1
assert summary.mean_accepted_views == 2.0
assert summary.mean_accepted_joints == 14.0
assert summary.mean_reprojection_error == 9.0
assert len(lines) == 2
assert "proposal_compatible" in lines[1]