fix(mapping): swap L/R joint assignments so the mirrored camera puts the player's right hand in HAND_RIGHT (was landing in HAND_LEFT); matches real Kinect convention. Update golden + occlusion tests.

This commit is contained in:
kinect-bot committed 2026-11-26 23:39:49 -05:00
1 parent 91c4e82ea6
commit cb5e8f7865
2 files changed
+40 -25

No files matched your search

+24 -16
View File
@@ -74,22 +74,30 @@ std::array<MediaPipeLandmark, contract::kJointCount> make_joint_landmarks(
? interpolate(joints[2], ears, 1.3f)
: landmarks[0];
joints[4] = landmarks[11];
joints[5] = landmarks[13];
joints[6] = landmarks[15];
joints[7] = hand_landmark(landmarks, 19, 17, 21, 15);
joints[8] = landmarks[12];
joints[9] = landmarks[14];
joints[10] = landmarks[16];
joints[11] = hand_landmark(landmarks, 20, 18, 22, 16);
joints[12] = landmarks[23];
joints[13] = landmarks[25];
joints[14] = landmarks[27];
joints[15] = landmarks[31];
joints[16] = landmarks[24];
joints[17] = landmarks[26];
joints[18] = landmarks[28];
joints[19] = landmarks[32];
// L/R are SWAPPED relative to MediaPipe's landmark labels because the tracker
// mirrors the camera (selfie view, matching a real Kinect's mirrored depth
// image). On a mirrored frame MediaPipe's RIGHT_* landmarks sit on the
// player's LEFT and vice-versa, so NUI LEFT joints take MediaPipe's right
// indices and NUI RIGHT joints take MediaPipe's left indices. This makes the
// player's right hand land in HAND_RIGHT (joint 11) with +x relative to
// SHOULDER_CENTER, matching real Kinect recordings (HAND_R-SHC.x in
// [-0.35,+0.86]); verified against the live log's moving hand.
joints[4] = landmarks[12];
joints[5] = landmarks[14];
joints[6] = landmarks[16];
joints[7] = hand_landmark(landmarks, 20, 18, 22, 16);
joints[8] = landmarks[11];
joints[9] = landmarks[13];
joints[10] = landmarks[15];
joints[11] = hand_landmark(landmarks, 19, 17, 21, 15);
joints[12] = landmarks[24];
joints[13] = landmarks[26];
joints[14] = landmarks[28];
joints[15] = landmarks[32];
joints[16] = landmarks[23];
joints[17] = landmarks[25];
joints[18] = landmarks[27];
joints[19] = landmarks[31];
return joints;
}
+16 -9
View File
@@ -65,27 +65,32 @@ TEST(mapping, ForwardInverseRoundTripStaysBelowOneMillimeter) {
}
TEST(mapping, LandmarkFixtureMapsAllTwentyJointsToGoldenPositions) {
// L/R joints are swapped vs MediaPipe labels (see make_joint_landmarks): the
// tracker mirrors the camera, so the player's right side comes from
// MediaPipe's left-side landmarks. NUI LEFT joints (4-7,12-15) therefore take
// the MediaPipe right-side fixture values and NUI RIGHT joints (8-11,16-19)
// take the left-side values.
const std::array<Vector4, nui::contract::kJointCount> expected{{
{0.14879250f, -0.14879250f, 2.5f, 1.0f},
{-0.07877250f, 0.07877250f, 2.5f, 1.0f},
{-0.35885250f, 0.35885250f, 2.5f, 1.0f},
{-0.57766500f, 0.57766500f, 2.5f, 1.0f},
{-0.37635750f, 0.37635750f, 2.5f, 1.0f},
{-0.29320875f, 0.29320875f, 2.5f, 1.0f},
{-0.21006000f, 0.21006000f, 2.5f, 1.0f},
{-0.08314875f, 0.08314875f, 2.5f, 1.0f},
{-0.33697125f, 0.33697125f, 2.5f, 1.0f},
{-0.25382250f, 0.25382250f, 2.5f, 1.0f},
{-0.16629750f, 0.16629750f, 2.5f, 1.0f},
{-0.04376250f, 0.04376250f, 2.5f, 1.0f},
{0.12691125f, -0.12691125f, 2.5f, 1.0f},
{0.21006000f, -0.21006000f, 2.5f, 1.0f},
{0.29320875f, -0.29320875f, 2.5f, 1.0f},
{0.46388250f, -0.46388250f, 2.5f, 1.0f},
{-0.37635750f, 0.37635750f, 2.5f, 1.0f},
{-0.29320875f, 0.29320875f, 2.5f, 1.0f},
{-0.21006000f, 0.21006000f, 2.5f, 1.0f},
{-0.08314875f, 0.08314875f, 2.5f, 1.0f},
{0.16629750f, -0.16629750f, 2.5f, 1.0f},
{0.25382250f, -0.25382250f, 2.5f, 1.0f},
{0.33697125f, -0.33697125f, 2.5f, 1.0f},
{0.50326875f, -0.50326875f, 2.5f, 1.0f},
{0.12691125f, -0.12691125f, 2.5f, 1.0f},
{0.21006000f, -0.21006000f, 2.5f, 1.0f},
{0.29320875f, -0.29320875f, 2.5f, 1.0f},
{0.46388250f, -0.46388250f, 2.5f, 1.0f},
}};
nui::mapping::MappingConfig config{};
config.mirror = false;
@@ -183,7 +188,9 @@ TEST(mapping, OccludedJointIsInferredAndHoldsLastSmoothedPosition) {
nui::mapping::SkeletonMapper mapper(config);
const auto visible_frame = mapper.map(landmarks);
const auto last_wrist = visible_frame.joints[6].position;
landmarks[15] = {0.0f, 0.0f, 0.0f, -100.0f};
// After the L/R swap, NUI WRIST_LEFT (joint 6) is fed by MediaPipe's
// RIGHT_WRIST (landmark 16), so occlude 16 to occlude joint 6.
landmarks[16] = {0.0f, 0.0f, 0.0f, -100.0f};
const auto occluded_frame = mapper.map(landmarks);