33 #include "objects/KinectUser.h" 34 #include "core/DataSkeleton.h" 35 #include "DeviceManager.h" 36 #include "generator/User.h" 37 #include "objects/KinectDevice.h" 38 #include "openNiScolPlugin.h" 41 KinectUser::KinectUser()
47 p_KinectDevice = pDevice;
60 KinectUser::~KinectUser()
63 p_KinectDevice->AddExistingId(uId);
65 if (p_KinectDevice->GetUserGenerator())
66 p_KinectDevice->GetUserGenerator()->stopTracking(
this);
68 SAFE_DELETE(mDataSkeleton);
70 SAFE_DELETE(mleftHand);
71 SAFE_DELETE(mrightHand);
82 void KinectUser::GenerateColor()
84 unsigned int r = rand() %255;
85 unsigned int g = rand() %255;
86 unsigned int b = rand() %255;
87 color = r + (g << 8) + (b << 16);
90 bool KinectUser::IsCalibrated()
95 void KinectUser::SetCalibrated(
bool state)
103 return p_KinectDevice;
108 return mDataSkeleton;
111 void KinectUser::SetId(
int id)
118 int KinectUser::GetId()
171 void KinectUser::DetectUserHands(cv::Mat depthMat, cv::Mat depthMatBgr)
173 mleftHand->Detect(depthMat, depthMatBgr);
174 mrightHand->Detect(depthMat, depthMatBgr);
177 bool KinectUser::GetBoneImgCoordinates(nite::JointType skelJoint, nite::Point3f &vec,
float minConfidence)
179 bool ret = mDataSkeleton->GetBoneImgCoordinates(skelJoint, vec, minConfidence);
180 if (skelJoint == nite::JOINT_LEFT_HAND)
181 vec = mleftHand->GetHandPos();
182 else if (skelJoint == nite::JOINT_RIGHT_HAND)
183 vec = mrightHand->GetHandPos();
188 bool KinectUser::GetBoneCurrentPosition(nite::JointType skelJoint, nite::Point3f &position,
float minConfidence)
190 return mDataSkeleton->GetBoneCurrentPosition(skelJoint, position, minConfidence);
193 bool KinectUser::GetBoneCurrentOrientation(nite::JointType skelJoint,
Quaternion* mQuat,
float minConfidence)
195 return mDataSkeleton->GetBoneCurrentOrientation(skelJoint, mQuat, minConfidence);
198 bool KinectUser::GetFingersPixelPosition(nite::JointType hand, vector<cv::Point> &vec)
200 if ((hand == nite::JOINT_LEFT_HAND) && (mleftHand->IsVisible()))
202 vec = mleftHand->GetFingersPos();
205 else if ((hand == nite::JOINT_RIGHT_HAND) && (mrightHand->IsVisible()))
207 vec = mrightHand->GetFingersPos();
214 bool KinectUser::IsHandVisible(nite::JointType skelJoint)
216 if (skelJoint == nite::JOINT_RIGHT_HAND)
218 return mrightHand->IsVisible();
220 else if (skelJoint == nite::JOINT_LEFT_HAND)
222 return mleftHand->IsVisible();
Kinect user hand handling. .
Kinect device handling. .