微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 硬件工程师文库 > 基于Dragonboard 410c的kinect应用系列之四——获取人体骨骼图

基于Dragonboard 410c的kinect应用系列之四——获取人体骨骼图

时间:02-21 来源:互联网 点击:
="line" id="LC366">/// <summary>

="line" id="LC367">/// Draws a skeleton

="line" id="LC368">/// </summary>

="line" id="LC369">/// <param name="skel">skeleton to draw</param>

="line" id="LC370">/// <param name="windowWidth">width (in pixels) of output buffer</param>

="line" id="LC371">/// <param name="windowHeight">height (in pixels) of output buffer</param>

="line" id="LC372">void CSkeletonBasics::DrawSkeleton(const NUI_SKELETON_DATA & skel, int windowWidth, int windowHeight)

="line" id="LC373">{

="line" id="LC374">int i;

="line" id="LC375"> 

="line" id="LC376">for (i = 0; i < NUI_SKELETON_POSITION_COUNT; ++i)

="line" id="LC377">{

="line" id="LC378">m_Points[i] = SkeletonToScreen(skel.SkeletonPositions[i], windowWidth, windowHeight);

="line" id="LC379">}

="line"> 

="line">

// Render Torso

DrawBone(skel, NUI_SKELETON_POSITION_HEAD, NUI_SKELETON_POSITION_SHOULDER_CENTER);

DrawBone(skel, NUI_SKELETON_POSITION_SHOULDER_CENTER, NUI_SKELETON_POSITION_SHOULDER_LEFT);

DrawBone(skel, NUI_SKELETON_POSITION_SHOULDER_CENTER, NUI_SKELETON_POSITION_SHOULDER_RIGHT);

DrawBone(skel, NUI_SKELETON_POSITION_SHOULDER_CENTER, NUI_SKELETON_POSITION_SPINE);

DrawBone(skel, NUI_SKELETON_POSITION_SPINE, NUI_SKELETON_POSITION_HIP_CENTER);

DrawBone(skel, NUI_SKELETON_POSITION_HIP_CENTER, NUI_SKELETON_POSITION_HIP_LEFT);

DrawBone(skel, NUI_SKELETON_POSITION_HIP_CENTER, NUI_SKELETON_POSITION_HIP_RIGHT);

 

// Left Arm

DrawBone(skel, NUI_SKELETON_POSITION_SHOULDER_LEFT, NUI_SKELETON_POSITION_ELBOW_LEFT);

DrawBone(skel, NUI_SKELETON_POSITION_ELBOW_LEFT, NUI_SKELETON_POSITION_WRIST_LEFT);

DrawBone(skel, NUI_SKELETON_POSITION_WRIST_LEFT, NUI_SKELETON_POSITION_HAND_LEFT);

 

// Right Arm

DrawBone(skel, NUI_SKELETON_POSITION_SHOULDER_RIGHT, NUI_SKELETON_POSITION_ELBOW_RIGHT);

DrawBone(skel, NUI_SKELETON_POSITION_ELBOW_RIGHT, NUI_SKELETON_POSITION_WRIST_RIGHT);

DrawBone(skel, NUI_SKELETON_POSITION_WRIST_RIGHT, NUI_SKELETON_POSITION_HAND_RIGHT);

 

// Left Leg

DrawBone(skel, NUI_SKELETON_POSITION_HIP_LEFT, NUI_SKELETON_POSITION_KNEE_LEFT);

DrawBone(skel, NUI_SKELETON_POSITION_KNEE_LEFT, NUI_SKELETON_POSITION_ANKLE_LEFT);

DrawBone(skel, NUI_SKELETON_POSITION_ANKLE_LEFT, NUI_SKELETON_POSITION_FOOT_LEFT);

 

// Right Leg

DrawBone(skel, NUI_SKELETON_POSITION_HIP_RIGHT, NUI_SKELETON_POSITION_KNEE_RIGHT);

DrawBone(skel, NUI_SKELETON_POSITION_KNEE_RIGHT, NUI_SKELETON_POSITION_ANKLE_RIGHT);

DrawBone(skel, NUI_SKELETON_POSITION_ANKLE_RIGHT, NUI_SKELETON_POSITION_FOOT_RIGHT);

 

// Draw the joints in a different color

for (i = 0; i < NUI_SKELETON_POSITION_COUNT; ++i)

{

D2D1_ELLIPSE ellipse = D2D1::Ellipse( m_Points[i], g_JointThickness, g_JointThickness );

 

if ( skel.eSkeletonPositionTrackingState[i] == NUI_SKELETON_POSITION_INFERRED )

{

m_pRenderTarget->DrawEllipse(ellipse, m_pBrushJointInferred);

}

else if ( skel.eSkeletonPositionTrackingState[i] == NUI_SKELETON_POSITION_TRACKED )

{

m_pRenderTarget->DrawEllipse(ellipse, m_pBrushJointTracked);

}

}

}

 

/// <summary>

/// Draws a bone line between two joints

/// </summary>

/// <param name="skel">skeleton to draw bones from</param>

/// <param name="joint0">joint to start drawing from</param>

/// <param name="joint1">joint to end drawing at</param>

void CSkeletonBasics::DrawBone(const NUI_SKELETON_DATA & sk

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top