基于Dragonboard 410c的kinect应用系列之四——获取人体骨骼图
时间:02-21
来源:互联网
点击:
="line" id="LC235"> }
="line" id="LC236">
break;
="line" id="LC237">
}
="line" id="LC238">
="line" id="LC239">
return FALSE;
="line" id="LC240">
}
="line" id="LC241">
="line" id="LC242">
/// <summary>
="line" id="LC243">
/// Create the first connected Kinect found
="line" id="LC244">
/// </summary>
="line" id="LC245">
/// <returns>indicates success or failure</returns>
="line" id="LC246">
HRESULT CSkeletonBasics::CreateFirstConnected()
="line" id="LC247">
{
="line" id="LC248">
INuiSensor * pNuiSensor;
="line" id="LC249">
="line" id="LC250">
int iSensorCount = 0;
="line" id="LC251">
HRESULT hr = NuiGetSensorCount(&iSensorCount);
="line" id="LC252">
if (FAILED(hr))
="line" id="LC253">
{
="line" id="LC254">
return hr;
="line" id="LC255">
}
="line" id="LC256">
="line" id="LC257">
// Look at each Kinect sensor
="line" id="LC258">
for (int i = 0; i < iSensorCount; ++i)
="line" id="LC259">
{
="line" id="LC260">
// Create the sensor so we can check status, if we can't create it, move on to the next
="line" id="LC261">
hr = NuiCreateSensorByIndex(i, &pNuiSensor);
="line" id="LC262">
if (FAILED(hr))
="line" id="LC263">
{
="line" id="LC264">
continue;
="line" id="LC265">
}
="line">
="line">
="line" id="LC267">
// Get the status of the sensor, and if connected, then we can initialize it
="line" id="LC268">
hr = pNuiSensor->NuiStatus();
="line" id="LC269">
if (S_OK == hr)
="line" id="LC270">
{
="line" id="LC271">
m_pNuiSensor = pNuiSensor;
="line" id="LC272">
break;
="line" id="LC273">
}
="line" id="LC274">
="line" id="LC275">
// This sensor wasn't OK, so release it since we're not using it
="line" id="LC276">
pNuiSensor->Release();
="line" id="LC277">
}
="line" id="LC278">
="line" id="LC279">
if (NULL != m_pNuiSensor)
="line" id="LC280">
{
="line" id="LC281">
// Initialize the Kinect and specify that we'll be using skeleton
="line" id="LC282">
hr = m_pNuiSensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON);
="line" id="LC283">
if (SUCCEEDED(hr))
="line" id="LC284">
{
="line" id="LC285">
// Create an event that will be signaled when skeleton data is available
="line" id="LC286">
m_hNextSkeletonEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
="line" id="LC287">
="line" id="LC288">
// Open a skeleton stream to receive skeleton data
="line" id="LC289">
hr = m_pNuiSensor->NuiSkeletonTrackingEnable(m_hNextSkeletonEvent, 0);
="line" id="LC290">
}
="line" id="LC291">
}
="line" id="LC292">
="line" id="LC293">
if (NULL == m_pNuiSensor || FAILED(hr))
="line" id="LC294">
{
="line" id="LC295">
SetStatusMessage(L"No ready Kinect found!");
="line" id="LC296">
return E_FAIL;
="line" id="LC297">
}
="line" id="LC298">
="line" id="LC299">
return hr;
="line" id="LC300">
}
="line">
="l
DragonBoard 410c Kinect 相关文章: