#include "stdafx.h" #include "SLJoints.h" // SL/OpenSim Joints static std::string _SLJointName[] = // SL_MAX_JOINT_NUM { "mPelvis", "mTorso", "mChest", "mNeck", "mHead", "mSkull", "mEyeLeft", "mEyeRight", "mCollarLeft", "mShoulderLeft", "mElbowLeft", "mWristLeft", "mCollarRight", "mShoulderRight", "mElbowRight", "mWristRight", "mHipLeft", "mKneeLeft", "mAnkleLeft", "mFootLeft", "mToeLeft", "mHipRight", "mKneeRight", "mAnkleRight", "mFootRight", "mToeRight", "L_Hand", "R_Hand", "Expression" }; std::string SLJointName(int n) { std::string str = ""; if (n>=0 && n 1: XN_SKEL_HEAD ○ × => [mHead(4)] 2: XN_SKEL_NECK ○ ○ => mNeck(3) 1 3: XN_SKEL_TORSO ○ ○ => mTrso(1) | 4: XN_SKEL_WAIST × × => none 9 - 7 - 6 - 2 - 12 - 13 - 15 5: XN_SKEL_LEFT_COLLAR × × => none | 6: XN_SKEL_LEFT_SHOULDER ○ ○ => mShoulderRight(13) 3 7: XN_SKEL_LEFT_ELBOW ○ ○ => mElbowRight(14) | 8: XN_SKEL_LEFT_WRIST × × => none 0 9: XN_SKEL_LEFT_HAND ○ × => [mWristRight(15)] 17 22 10: XN_SKEL_LEFT_FINGERTIP × × => none | | 11: XN_SKEL_RIGHT_COLLAR × × => none 18 22 12: XN_SKEL_RIGHT_SHOULDER ○ ○ => mShoulderLeft(9) | | 13: XN_SKEL_RIGHT_ELBOW ○ ○ => mElbowLeft(10) 20 24 14: XN_SKEL_RIGHT_WRIST × × => none 15: XN_SKEL_RIGHT_HAND ○ × => [mWristLeft(11)] 16: XN_SKEL_RIGHT_FINGERTIP × × => none 17: XN_SKEL_LEFT_HIP ○ ○ => mHipRight(21) 18: XN_SKEL_LEFT_KNEE ○ ○ => mKneeRight(22) 19: XN_SKEL_LEFT_ANKLE × × => none 20: XN_SKEL_LEFT_FOOT ○ × => [mFootLeft(24)] 21: XN_SKEL_RIGHT_HIP ○ ○ => mHipLeft(16) 22: XN_SKEL_RIGHT_KNEE ○ ○ => mKneeLeft(17) 23: XN_SKEL_RIGHT_ANKLE × × => none 24: XN_SKEL_RIGHT_FOOT ○ × => [mFootLeft(19)] */ static int _OpenNI2SLPosJoint[] = // OPENNI_MAX_JOINT_NUM { 0, 4, 3, 1, -1, -1, 13, 14, -1, 15, -1, -1, 9, 10, -1, 11, -1, 21, 22, -1, 24, 16, 17, -1, 19 }; static int _OpenNI2SLRotJoint[] = // OPENNI_MAX_JOINT_NUM { 0, -1, 3, 1, -1, -1, 13, 14, -1, -1, -1, -1, 9, 10, -1, -1, -1, 21, 22, -1, -1, 16, 17, -1, -1 }; int OpenNI2SLPosJointNum(int n) { return _OpenNI2SLPosJoint[n]; } int OpenNI2SLRotJointNum(int n) { return _OpenNI2SLRotJoint[n]; } //////////////////////////////////////////////////////////////////////////////////////// // // Kinect SDK // /* 0: NUI_SKELETON_POSITION_HIP_CENTER => mPelvis(0) 1: NUI_SKELETON_POSITION_SPINE => 2: NUI_SKELETON_POSITION_SHOULDER_CENTER => mNeck(3) 3: NUI_SKELETON_POSITION_HEAD => [mHead(4)] 3 4: NUI_SKELETON_POSITION_SHOULDER_LEFT => mShoulderLeft(9) | 5: NUI_SKELETON_POSITION_ELBOW_LEFT => mElbowLeft(10) 11 - 10 - 9 - 8 - 2 - 4 - 5 - 6 - 7 6: NUI_SKELETON_POSITION_WRIST_LEFT => mWristLeft(11) | 7: NUI_SKELETON_POSITION_HAND_LEFT => none 1 8: NUI_SKELETON_POSITION_SHOULDER_RIGHT => mShoulderRight(13) | 9: NUI_SKELETON_POSITION_ELBOW_RIGHT => mElbowRight(14) 16 0 12 10: NUI_SKELETON_POSITION_WRIST_RIGHT => mWristRight(15) | | 11: NUI_SKELETON_POSITION_HAND_RIGHT => none 17 13 12: NUI_SKELETON_POSITION_HIP_LEFT => mHipLeft(16) | | 13: NUI_SKELETON_POSITION_KNEE_LEFT => mKneeLeft(17) 18 14 14: NUI_SKELETON_POSITION_ANKLE_LEFT => mAnkleLeft(18) | | 15: NUI_SKELETON_POSITION_FOOT_LEFT => [mFootLeft(19)] 19 15 16: NUI_SKELETON_POSITION_HIP_RIGHT => mHipRight(21) 17: NUI_SKELETON_POSITION_KNEE_RIGHT => mKneeRight(22) 18: NUI_SKELETON_POSITION_ANKLE_RIGHT => mAnkleRight(23) 19: NUI_SKELETON_POSITION_FOOT_RIGHT => [mFootRight(24)] */ static int _Kinect2SLPosJoint[] = // KINECT_MAX_JOINT_NUM { 0, 1, 3, 4, 9, 10, 11, -1, 13, 14, 15, -1, 16, 17, 18, 19, 21, 22, 23, 24 }; static int _Kinect2SLRotJoint[] = // KINECT_MAX_JOINT_NUM { 0, 1, 3, -1, 9, 10, 11, -1, 13, 14, 15, -1, 16, 17, 18, -1, 21, 22, 23, -1 }; int Kinect2SLRotJointNum(int n) { return _Kinect2SLRotJoint[n]; } int Kinect2SLPosJointNum(int n) { return _Kinect2SLPosJoint[n]; } //////////////////////////////////////////////////////////////////////////////////////// // // 共通ジョイント番号 // /* #define NI_PELVIS 0 => mPelvis(0) #define NI_TORSO 1 => mTorso(1) #define NI_WAIST 2 => none #define NI_CHEST 3 => mChest(2) #define NI_NECK 4 => mNeck(3) #define NI_HEAD 5 => mHead(4) #define NI_SKULL 6 => [mSkull(5)] #define NI_L_EYE 7 => mEyeLeft(6) #define NI_R_EYE 8 => mEyeRight(7) #define NI_L_BUST 9 => none #define NI_R_BUST 10 => none #define NI_L_COLLAR 11 => mCollarLeft(8) #define NI_L_SHLDR 12 => mShoulderLeft(9) #define NI_L_ELBOW 13 => mElbowLeft(10) #define NI_L_WRIST 14 => mWristLeft(11) #define NI_L_HAND 15 => none #define NI_R_COLLAR 16 => mCollarRight(12) #define NI_R_SHLDR 17 => mShoulderRight(13) #define NI_R_ELBOW 18 => mElbowRight(14) #define NI_R_WRIST 19 => mWristRight(15) #define NI_R_HAND 20 => none #define NI_L_HIP 21 => mHipLeft(16) #define NI_L_KNEE 22 => mKneeLeft(17) #define NI_L_ANKLE 23 => mAnkleLeft(18) #define NI_L_FOOT 24 => mFootLeft(19) #define NI_L_TOE 25 => [mToeLeft(20)] #define NI_R_HIP 26 => mHipRight(21) #define NI_R_KNEE 27 => mKneeRight(22) #define NI_R_ANKLE 28 => mAnkleRight(23) #define NI_R_FOOT 29 => mFootRight(24) #define NI_R_TOE 30 => [mToeRight(25)] #define NI_L_FINGER 31 => L_Hand(26) #define NI_R_FINGER 32 => R_Hand(27) #define NI_FACE 33 => FACE(28) */ static int _Ni2SLPosJoint[] = // NI_JOINT_NUM (34) { 0, 1, -1, 2, 3, 4, 5, 6, 7, -1, -1, 8, 9, 10, 11, -1, 12, 13, 14, 15, -1, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 }; static int _Ni2SLRotJoint[] = // NI_JOINT_NUM (34) { 0, 1, -1, 2, 3, 4, -1, 6, 7, -1, -1, 8, 9, 10, 11, -1, 12, 13, 14, 15, -1, 16, 17, 18, 19, -1, 21, 22, 23, 24, -1, 26, 27, 28 }; int Ni2SLPosJointNum(int n) { return _Ni2SLRotJoint[n]; } int Ni2SLRotJointNum(int n) { return _Ni2SLRotJoint[n]; } //////////////////////////////////////////////////////////////////////////////////////// // // Wrapper // // // Library 固有のジョイント番号から SL/OSの座標用ジョイント番号を得る // int NiSDK2SLPosJointNum(int n, NiSDK_Lib lib) { if (lib==NiSDK_OpenNI) { return _OpenNI2SLPosJoint[n]; } else if (lib==NiSDK_Kinect) { return _Kinect2SLPosJoint[n]; } else if (lib==NiSDK_None) { return _Ni2SLPosJoint[n]; } return -1; } // // Library 固有のジョイント番号から SL/OSの回転用ジョイント番号を得る // int NiSDK2SLRotJointNum(int n, NiSDK_Lib lib) { if (lib==NiSDK_OpenNI) { return _OpenNI2SLRotJoint[n]; } else if (lib==NiSDK_Kinect) { return _Kinect2SLRotJoint[n]; } else if (lib==NiSDK_None) { return _Ni2SLRotJoint[n]; } return -1; } // // Library 固有のジョイント番号から SL/OSの座標用ジョイント名を得る // std::string NiSDK2SLPosJointName(int n, NiSDK_Lib lib) { std::string str = ""; int j = -1; if (lib==NiSDK_OpenNI) { j = _OpenNI2SLPosJoint[n]; } else if (lib==NiSDK_Kinect) { j = _Kinect2SLPosJoint[n]; } else if (lib==NiSDK_None) { j = _Ni2SLPosJoint[n]; } if (j>=0) str = _SLJointName[j]; return str; } // // Library 固有のジョイント番号から SL/OSの回転用ジョイント名を得る // std::string NiSDK2SLRotJointName(int n, NiSDK_Lib lib) { std::string str = ""; int j = -1; if (lib==NiSDK_OpenNI) { j = _OpenNI2SLRotJoint[n]; } else if (lib==NiSDK_Kinect) { j = _Kinect2SLRotJoint[n]; } else if (lib==NiSDK_None) { j = _Ni2SLRotJoint[n]; } if (j>=0) str = _SLJointName[j]; return str; } // // 共通ジョイント番号から SL/OSの座標用ジョイント名を得る // std::string Ni2SLPosJointName(int n) { std::string str = ""; int j = _Ni2SLPosJoint[n]; if (j>=0) str = _SLJointName[j]; return str; } // // 共通ジョイント番号から SL/OSの回転用ジョイント名を得る // std::string Ni2SLRotJointName(int n) { std::string str = ""; int j = _Ni2SLRotJoint[n]; if (j>=0) str = _SLJointName[j]; return str; }