inect for Windows SDK v2.0 public preview
本次讨论的主题是骨骼帧的获取,这也是Kinect的主要卖点之一。如果使用其他数据,我们完全可以购买其他产品来满足需求,但Kinect的独特之处正是在于它的骨骼跟踪功能。现在让我们来看一下SDK此次支持的骨骼关节有哪些。
以下是根据您提供的内容重构的代码:
```c++
enum _JointType { JointType_SpineBase = 0, JointType_SpineMid = 1, JointType_Neck = 2, JointType_Head = 3, JointType_ShoulderLeft = 4, JointType_ElbowLeft = 5, JointType_WristLeft = 6, JointType_HandLeft = 7, JointType_ShoulderRight = 8, JointType_ElbowRight = 9, JointType_WristRight = 10, JointType_HandRight = 11, JointType_HipLeft = 12, JointType_KneeLeft = 13, JointType_AnkleLeft = 14, JointType_FootLeft = 15, JointType_HipRight = 16, JointType_KneeRight = 17, JointType_AnkleRight = 18, JointType_FootRight = 19, JointType_SpineShoulder = 20, JointType_HandTipLeft = 21, JointType_ThumbLeft = 22, JointType_HandTipRight = 23, JointType_ThumbRight = 24, JointType_Count = ( JointType_ThumbRight + 1 ) };
struct JointState
{
int jointIndex;
int state;
};
// 支持这25个关节点,不排除会增加的可能,毕竟近景可以分辨十指。
JointState jointStates[JointType::JointType_Count];
```
每个关节的状态用`JointState`结构体描述。
```cpp
typedef struct _Joint {
JointType JointType; // 关节编号
CameraSpacePoint Position; // Kinect相机空间坐标,三维坐标
TrackingState TrackingState; // 关节追踪状态,有未追踪(0),位置推测(1),位置追踪(2)三种状态
} Joint;
enum _HandState {
HandState_Unknown = 0,
HandState_NotTracked = 1,
HandState_Open = 2,
HandState_Closed = 3,
HandState_Lasso = 4
};
// 使用方法和之前的差不多,主要区别在于这次C++的SDK提供了判断手的状态的功能。
IBody* ppBodies[BODY_COUNT]; // 假设已经定义了IBody结构体指针数组ppBodies
```