Kinect for Windows V2和V1对比开发___多台Kinect的使用

对于V1

<span style="white-space:pre">	</span>INuiSensor * pNuiSensor;
	HRESULT hr;
	int iSensorCount = 0;
	hr = NuiGetSensorCount(&iSensorCount);
	if (FAILED(hr))
	{
		return hr;
	}
	//轮询每一个Kinect sensor
	for (int i = 0; i < iSensorCount; ++i)
	{
		// Create the sensor so we can check status, if we can't create it, move on to the next
		hr = NuiCreateSensorByIndex(i, &pNuiSensor);
		if (FAILED(hr))
		{
			continue;
		}
		// 得到传感器状态, and 如果已连接,进行初始化
		hr = pNuiSensor->NuiStatus();
		if (S_OK == hr)
		{
			m_PNuiSensor = pNuiSensor;
			break;
		}
		//既然不使用,释放
		pNuiSensor->Release();
	}

对于V2


//多台kinect
    IKinectSensorCollection* pKinectCollection = nullptr;
    IEnumKinectSensor* pEnumKinect = nullptr;
    IKinectSensor* pKinect = nullptr;
    // 获取Kinect集合
    HRESULT hr = ::GetKinectSensorCollection(&pKinectCollection);
    // 获取Kinect枚举器
    if (SUCCEEDED(hr)){
        hr = pKinectCollection->get_Enumerator(&pEnumKinect);
    }
    // 枚举Kinect
    if (SUCCEEDED(hr)){
        BOOLEAN available = false;
        while (true){
            // 获取下一个
            if (SUCCEEDED(pEnumKinect->GetNext(&pKinect))){
                // 判断有效性
                pKinect->get_IsAvailable(&available);
                if (available && YourJudgmentFunc(pKinect)){
                    break;
                }
                SafeRelease(pKinect);
            }
            else
                break;
        }
    }
    SafeRelease(pEnumKinect);
    SafeRelease(pKinectCollection);




Kinect for Windows V2和V1对比开发___多台Kinect的使用

上一篇:Flask中session和cookies的使用


下一篇:淘宝爬虫实战(附代码和数据集)——今天你防脱发了吗?