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

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

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

="line" id="LC303"> /// Handle new skeleton data

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

="line" id="LC305"> void CSkeletonBasics::ProcessSkeleton()

="line" id="LC306"> {

="line" id="LC307"> NUI_SKELETON_FRAME skeletonFrame = {0};

="line" id="LC308">  

="line" id="LC309"> HRESULT hr = m_pNuiSensor->NuiSkeletonGetNextFrame(0, &skeletonFrame);

="line" id="LC310"> if ( FAILED(hr) )

="line" id="LC311"> {

="line" id="LC312"> return;

="line" id="LC313"> }

="line" id="LC314">  

="line" id="LC315"> // smooth out the skeleton data

="line" id="LC316"> m_pNuiSensor->NuiTransformSmooth(&skeletonFrame, NULL);

="line" id="LC317">  

="line" id="LC318"> // Endure Direct2D is ready to draw

="line" id="LC319"> hr = EnsureDirect2DResources( );

="line" id="LC320"> if ( FAILED(hr) )

="line" id="LC321"> {

="line" id="LC322"> return;

="line" id="LC323"> }

="line" id="LC324">  

="line" id="LC325"> m_pRenderTarget->BeginDraw();

="line" id="LC326"> m_pRenderTarget->Clear( );

="line" id="LC327">  

="line" id="LC328"> RECT rct;

="line" id="LC329"> GetClientRect( GetDlgItem( m_hWnd, IDC_VIDEOVIEW ), &rct);

="line" id="LC330"> int width = rct.right;

="line" id="LC331"> int height = rct.bottom;

="line" id="LC332">  

="line" id="LC333"> for (int i = 0 ; i < NUI_SKELETON_COUNT; ++i)

="line" id="LC334"> {

="line" id="LC335"> NUI_SKELETON_TRACKING_STATE trackingState = skeletonFrame.SkeletonData[i].eTrackingState;

="line" id="LC336">  

="line" id="LC337"> if (NUI_SKELETON_TRACKED == trackingState)

="line" id="LC338"> {

="line" id="LC339"> // We're tracking the skeleton, draw it

="line" id="LC340"> DrawSkeleton(skeletonFrame.SkeletonData[i], width, height);

="line" id="LC341"> }

="line" id="LC342"> else if (NUI_SKELETON_POSITION_ONLY == trackingState)

="line"> ="line" id="LC343">{

="line" id="LC344">// we've only received the center point of the skeleton, draw that

="line" id="LC345">D2D1_ELLIPSE ellipse = D2D1::Ellipse(

="line" id="LC346">SkeletonToScreen(skeletonFrame.SkeletonData[i].Position, width, height),

="line" id="LC347">g_JointThickness,

="line" id="LC348">g_JointThickness

="line" id="LC349">);

="line" id="LC350"> 

="line" id="LC351">m_pRenderTarget->DrawEllipse(ellipse, m_pBrushJointTracked);

="line" id="LC352">}

="line" id="LC353">}

="line" id="LC354"> 

="line" id="LC355">hr = m_pRenderTarget->EndDraw();

="line" id="LC356"> 

="line" id="LC357">// Device lost, need to recreate the render target

="line" id="LC358">// We'll dispose it now and retry drawing

="line" id="LC359">if (D2DERR_RECREATE_TARGET == hr)

="line" id="LC360">{

="line" id="LC361">hr = S_OK;

="line" id="LC362">DiscardDirect2DResources();

="line" id="LC363">}

="line" id="LC364">}

="line" id="LC365">  ="line" id="LC366">/// <summary

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

网站地图

Top