| 314 | } |
| 315 | |
| 316 | XnStatus UserTracker::GetLimbs(XnUserID nUserID, XnPoint3D *pLimbs,XnFloat *pConfidence, XnUInt16 &numLimbs) |
| 317 | { |
| 318 | // following is a static array of the limbs to draw. Each pair represents a line which |
| 319 | // should be drawn |
| 320 | static XnSkeletonJoint jointsToPrint[][2] = |
| 321 | { |
| 322 | { XN_SKEL_HEAD, XN_SKEL_NECK }, |
| 323 | { XN_SKEL_NECK, XN_SKEL_LEFT_SHOULDER }, |
| 324 | { XN_SKEL_LEFT_SHOULDER, XN_SKEL_LEFT_ELBOW }, |
| 325 | { XN_SKEL_LEFT_ELBOW, XN_SKEL_LEFT_HAND }, |
| 326 | { XN_SKEL_NECK, XN_SKEL_RIGHT_SHOULDER }, |
| 327 | { XN_SKEL_RIGHT_SHOULDER, XN_SKEL_RIGHT_ELBOW }, |
| 328 | { XN_SKEL_RIGHT_ELBOW, XN_SKEL_RIGHT_HAND }, |
| 329 | { XN_SKEL_LEFT_SHOULDER, XN_SKEL_TORSO }, |
| 330 | { XN_SKEL_RIGHT_SHOULDER, XN_SKEL_TORSO }, |
| 331 | { XN_SKEL_TORSO, XN_SKEL_LEFT_HIP }, |
| 332 | { XN_SKEL_LEFT_HIP, XN_SKEL_LEFT_KNEE }, |
| 333 | { XN_SKEL_LEFT_KNEE, XN_SKEL_LEFT_FOOT }, |
| 334 | { XN_SKEL_TORSO, XN_SKEL_RIGHT_HIP }, |
| 335 | { XN_SKEL_RIGHT_HIP, XN_SKEL_RIGHT_KNEE }, |
| 336 | { XN_SKEL_RIGHT_KNEE, XN_SKEL_RIGHT_FOOT }, |
| 337 | { XN_SKEL_LEFT_HIP, XN_SKEL_RIGHT_HIP }, |
| 338 | }; |
| 339 | static XnUInt16 MaxNumLimbs=16; |
| 340 | |
| 341 | if (!m_UserGenerator.GetSkeletonCap().IsTracking(nUserID)) |
| 342 | { |
| 343 | return XN_STATUS_NO_SUCH_USER; |
| 344 | } |
| 345 | |
| 346 | XnUInt16 limbCount=0; |
| 347 | XnSkeletonJointPosition joint1, joint2; |
| 348 | for(XnUInt16 i=0; i<MaxNumLimbs; i++) |
| 349 | { |
| 350 | if(limbCount>=numLimbs) |
| 351 | break; // we can't put any new ones |
| 352 | |
| 353 | if(m_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nUserID, jointsToPrint[i][0], joint1)!=XN_STATUS_OK) |
| 354 | { |
| 355 | continue; // bad joint |
| 356 | } |
| 357 | if(m_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nUserID, jointsToPrint[i][1], joint2)!=XN_STATUS_OK) |
| 358 | { |
| 359 | continue; // bad joint |
| 360 | } |
| 361 | |
| 362 | pConfidence[limbCount]=joint1.fConfidence; |
| 363 | if(pConfidence[limbCount]>joint2.fConfidence) |
| 364 | { |
| 365 | pConfidence[limbCount]=joint2.fConfidence; |
| 366 | } |
| 367 | pLimbs[limbCount*2] = joint1.position; |
| 368 | pLimbs[(limbCount*2)+1] = joint2.position; |
| 369 | limbCount++; |
| 370 | } |
| 371 | if(limbCount>0) |
| 372 | m_DepthGenerator.ConvertRealWorldToProjective(limbCount*2, pLimbs, pLimbs); |
| 373 | numLimbs=limbCount; |
no test coverage detected