32 #include "core/DataSkeleton.h" 33 #include "generator/User.h" 34 #include "generator/Depth.h" 35 #include "objects/KinectDevice.h" 36 #include "objects/KinectUser.h" 38 DataSkeleton::DataSkeleton(
KinectUser* existingUser)
40 p_User = existingUser;
43 DataSkeleton::DataSkeleton()
48 DataSkeleton::~DataSkeleton()
53 bool DataSkeleton::GetBoneCurrentPosition(nite::JointType jointType, nite::Point3f &position,
float minConfidence)
55 if (p_User && p_User->GetParentDevice()->GetUserGenerator() != 0 && p_User->GetParentDevice()->GetUserGenerator()->IsValid())
57 nite::UserTracker* pUserTracker = p_User->GetParentDevice()->GetUserGenerator()->GetUserTraker();
58 nite::UserTrackerFrameRef* pTrakerFrame = p_User->GetParentDevice()->GetUserGenerator()->GetTrakerFrame();
59 const nite::UserData* userData = pTrakerFrame->getUserById((nite::UserId)p_User->GetId());
60 if (userData && userData->isVisible())
62 const nite::Skeleton skl = userData->getSkeleton();
63 if (skl.getState() == nite::SKELETON_TRACKED)
65 const nite::SkeletonJoint joint = skl.getJoint(jointType);
66 if (joint.getPositionConfidence() < minConfidence)
69 position = joint.getPosition();
77 bool DataSkeleton::GetBoneImgCoordinates(nite::JointType jointType, nite::Point3f &v,
float minConfidence)
79 if (p_User && p_User->GetParentDevice()->GetUserGenerator() != 0 && p_User->GetParentDevice()->GetUserGenerator()->IsValid())
81 nite::UserTracker* pUserTracker = p_User->GetParentDevice()->GetUserGenerator()->GetUserTraker();
82 nite::UserTrackerFrameRef* pTrakerFrame = p_User->GetParentDevice()->GetUserGenerator()->GetTrakerFrame();
83 const nite::UserData* userData = pTrakerFrame->getUserById(p_User->GetId());
84 if (userData && userData->isVisible())
86 const nite::Skeleton skl = userData->getSkeleton();
87 if (skl.getState() == nite::SKELETON_TRACKED)
89 const nite::SkeletonJoint joint = skl.getJoint(jointType);
90 if (joint.getPositionConfidence() < minConfidence)
94 if (pUserTracker->convertJointCoordinatesToDepth(joint.getPosition().x, joint.getPosition().y, joint.getPosition().z, &x, &y) != nite::STATUS_OK)
99 v.z = joint.getPosition().z;
108 bool DataSkeleton::GetBoneCurrentOrientation(nite::JointType jointType,
Quaternion* mQuat,
float minConfidence)
110 if (p_User && p_User->GetParentDevice()->GetUserGenerator() != 0 && p_User->GetParentDevice()->GetUserGenerator()->IsValid())
112 nite::UserTracker* pUserTracker = p_User->GetParentDevice()->GetUserGenerator()->GetUserTraker();
113 nite::UserTrackerFrameRef* pTrakerFrame = p_User->GetParentDevice()->GetUserGenerator()->GetTrakerFrame();
114 const nite::UserData* userData = pTrakerFrame->getUserById(p_User->GetId());
115 if (userData && userData->isVisible())
117 const nite::Skeleton skl = userData->getSkeleton();
118 if (skl.getState() == nite::SKELETON_TRACKED)
120 const nite::SkeletonJoint joint = skl.getJoint(jointType);
121 if (joint.getOrientationConfidence() < minConfidence)
124 const nite::Quaternion jquat = joint.getOrientation();