Add tracked triangulation association reports
This commit is contained in:
+60
-2
@@ -119,11 +119,19 @@ def test_triangulate_accepts_empty_previous_poses():
|
||||
poses_2d, person_counts, cameras = load_case("data/p1/sample.json", "tests/poses_p1.json")
|
||||
config = make_config(cameras, [[5.6, 6.4, 2.4], [0.0, -0.5, 1.2]])
|
||||
empty_previous = np.zeros((0, len(JOINT_NAMES), 4), dtype=np.float32)
|
||||
empty_previous_ids = np.zeros((0,), dtype=np.int64)
|
||||
|
||||
baseline = rpt.triangulate_poses(poses_2d, person_counts, config)
|
||||
with_previous = rpt.triangulate_poses(poses_2d, person_counts, config, empty_previous)
|
||||
result = rpt.triangulate_with_report(
|
||||
poses_2d,
|
||||
person_counts,
|
||||
config,
|
||||
empty_previous,
|
||||
empty_previous_ids,
|
||||
)
|
||||
|
||||
np.testing.assert_allclose(with_previous, baseline, rtol=1e-5, atol=1e-5)
|
||||
np.testing.assert_allclose(result.poses_3d, baseline, rtol=1e-5, atol=1e-5)
|
||||
assert result.association.unmatched_previous_track_ids == []
|
||||
|
||||
|
||||
def test_triangulate_debug_matches_final_output():
|
||||
@@ -135,6 +143,7 @@ def test_triangulate_debug_matches_final_output():
|
||||
|
||||
np.testing.assert_allclose(trace.final_poses, final_poses, rtol=1e-5, atol=1e-5)
|
||||
assert len(trace.pairs) >= len(trace.core_proposals)
|
||||
assert trace.association.pose_previous_track_ids == []
|
||||
for group in trace.grouping.groups:
|
||||
assert all(0 <= index < len(trace.core_proposals) for index in group.proposal_indices)
|
||||
for merge_indices in trace.merge.group_proposal_indices:
|
||||
@@ -145,18 +154,67 @@ def test_filter_pairs_with_previous_poses_returns_debug_matches():
|
||||
poses_2d, person_counts, cameras = load_case("data/p1/sample.json", "tests/poses_p1.json")
|
||||
config = make_config(cameras, [[5.6, 6.4, 2.4], [0.0, -0.5, 1.2]])
|
||||
previous_poses = rpt.triangulate_poses(poses_2d, person_counts, config)
|
||||
previous_track_ids = np.arange(previous_poses.shape[0], dtype=np.int64) + 100
|
||||
|
||||
debug = rpt.filter_pairs_with_previous_poses(
|
||||
poses_2d,
|
||||
person_counts,
|
||||
config,
|
||||
previous_poses,
|
||||
previous_track_ids,
|
||||
)
|
||||
|
||||
assert debug.used_previous_poses is True
|
||||
assert len(debug.matches) == len(rpt.build_pair_candidates(poses_2d, person_counts))
|
||||
assert len(debug.kept_pairs) == len(debug.kept_pair_indices)
|
||||
assert any(match.matched_view1 or match.matched_view2 for match in debug.matches)
|
||||
assert any(match.previous_track_id >= 100 for match in debug.matches if match.previous_pose_index >= 0)
|
||||
|
||||
|
||||
def test_triangulate_with_report_resolves_previous_track_ids():
|
||||
poses_2d, person_counts, cameras = load_case("data/p1/sample.json", "tests/poses_p1.json")
|
||||
config = make_config(cameras, [[5.6, 6.4, 2.4], [0.0, -0.5, 1.2]])
|
||||
previous_poses = rpt.triangulate_poses(poses_2d, person_counts, config)
|
||||
previous_track_ids = np.arange(previous_poses.shape[0], dtype=np.int64) + 100
|
||||
|
||||
result = rpt.triangulate_with_report(
|
||||
poses_2d,
|
||||
person_counts,
|
||||
config,
|
||||
previous_poses,
|
||||
previous_track_ids,
|
||||
)
|
||||
|
||||
assert result.poses_3d.shape == previous_poses.shape
|
||||
assert len(result.association.pose_previous_track_ids) == result.poses_3d.shape[0]
|
||||
matched_track_ids = sorted(
|
||||
track_id for track_id in result.association.pose_previous_track_ids if track_id >= 0
|
||||
)
|
||||
unmatched_track_ids = sorted(result.association.unmatched_previous_track_ids)
|
||||
|
||||
for pose_index in result.association.new_pose_indices:
|
||||
assert result.association.pose_previous_track_ids[pose_index] == -1
|
||||
for pose_index in result.association.ambiguous_pose_indices:
|
||||
assert result.association.pose_previous_track_ids[pose_index] == -1
|
||||
|
||||
assert matched_track_ids == sorted(set(matched_track_ids))
|
||||
assert sorted(matched_track_ids + unmatched_track_ids) == list(previous_track_ids)
|
||||
|
||||
|
||||
def test_triangulate_with_report_rejects_duplicate_previous_track_ids():
|
||||
poses_2d, person_counts, cameras = load_case("data/p1/sample.json", "tests/poses_p1.json")
|
||||
config = make_config(cameras, [[5.6, 6.4, 2.4], [0.0, -0.5, 1.2]])
|
||||
previous_poses = rpt.triangulate_poses(poses_2d, person_counts, config)
|
||||
duplicate_ids = np.zeros((previous_poses.shape[0],), dtype=np.int64)
|
||||
|
||||
with pytest.raises(ValueError, match="unique"):
|
||||
rpt.triangulate_with_report(
|
||||
poses_2d,
|
||||
person_counts,
|
||||
config,
|
||||
previous_poses,
|
||||
duplicate_ids,
|
||||
)
|
||||
|
||||
|
||||
def test_triangulate_does_not_mutate_inputs():
|
||||
|
||||
Reference in New Issue
Block a user