How to check if any Kinect device is connected with system ?

By | August 7, 2013

If you are dealing with Kinect based application, It is always good practice to first check if there is any Kinect sensor connected with the PC before doing any operation with KinectSensor objects. The KinectSensors holds the reference of all connected sensors and as this is a collection, it has a Count property.  You can use the KinectSensors.Count to check the number of device. The device count will more than 0, only if there is one or more device is connected.

int deviceCount = KinectSensor.KinectSensors.Count;
if (deviceCount > 0)
{

this.sensor = KinectSensor.KinectSensors[0];
// Rest operation here
}
else
{
// No sensor connected.
}

Consider, you have one device connected, so you will get reference of connected sensor as shown in below code snippet.

this.sensor = KinectSensor.KinectSensors[0];

Once you have the Sensor object of the Kinect device, invoke KinectSensor.Start() method to start the sensor.

2 thoughts on “How to check if any Kinect device is connected with system ?

  1. Pingback: glove dotting machine

  2. Pingback: .NET Tips and Tricks from Daily .NET Tips – July and August 2013 Links | Abhijit's World of .NET

Comments are closed.