Identify Kinect device index from device instance id

By | August 16, 2013

In one of our previous tip ( Using Kinect Instance Id to Initialize the Kinect Sensor ) we have seen how we can initialize Kinect device using the instance id. In this tip, you will see how we can use the instance id to get the device index position.

First of all, you can use below code snippet to get the DeviceConnectionId

inectSensor sensor = KinectSensor.KinectSensors [@" USUSB\VID_0409&PID_005A&35F09B95&0&3"];
int deviceConnectionID = sensor.DeviceConnectionId

Now, you can refer to the device using the deviceConnectionID as shown in the following code block:

int currentPosition = 0;
var collection = KinectSensor.KinectSensors.Where(item => item.DeviceConnectionId == deviceConnectionID );
var indexCollection = from item in collection
let row = currentPosition++
select new { SensorObject = item, SensorIndex = row };

If  you have only one sensor is connected, the index should be 0. You can use the above code block for multiple Kinect sensors as well.
Device Index From Kinect InstaceID