For V1
<span style= "White-space:pre" ></span>inuisensor * pnuisensor; HRESULT Hr;int isensorcount = 0;hr = Nuigetsensorcount (&isensorcount); if (FAILED (HR)) {return hr;} Poll each Kinect sensorfor (int i = 0; i < Isensorcount; ++i) {//Create the sensor so we can check status, if we can ' t cre Ate it, move on to the NEXTHR = Nuicreatesensorbyindex (i, &pnuisensor); if (FAILED (HR)) {continue;} Get the sensor status, and if connected, initialize hr = Pnuisensor->nuistatus (); if (S_OK = = hr) {m_pnuisensor = Pnuisensor;break;} If not used, release pnuisensor->release ();}
For V2
More than one Kinect
ikinectsensorcollection* pkinectcollection = nullptr; ienumkinectsensor* penumkinect = nullptr; ikinectsensor* pkinect = nullptr; Get Kinect collection HRESULT hr =:: Getkinectsensorcollection (&pkinectcollection); Gets the Kinect enumerator if (SUCCEEDED (HR)) { hr = Pkinectcollection->get_enumerator (&penumkinect); } Enumerates the Kinect if (SUCCEEDED (HR)) { BOOLEAN available = false; while (true) { //Gets the next if (SUCCEEDED (Penumkinect->getnext (&pkinect))) { //judging validity Pkinect->get_isavailable (&available); if (Available && Yourjudgmentfunc (Pkinect)) {break ; } Saferelease (Pkinect); } else break ; } } Saferelease (penumkinect); Saferelease (pkinectcollection);
Kinect for Windows V2 and V1 to develop the use of more than ___ Kinect