How to get list of all Connected Kinect Sensor ?

By | August 12, 2013

This tip shows you how to get list of all the Kinect sensor which are connected with system.  The KinectSensor class has a static property of type KinectSensorCollection, named KinectSenors which consists of the collection of sensors that are connected with system.

To see if the sensor is connected with the system , we can use the Status property of the KinectSensor class. The KinectSensor object has a property named Status, which indicates the current state of the devices. The property is type of KinectStatus enumeration.  A status with  KinectStatus.Connected  indicates, device is connected properly with the system and can be used to for consuming data using application.

You can use following code snippet to get list of connected sensor’s connection id.

Console.WriteLine("Number of Kinect Sensor(s) Connected : {0}", KinectSensor.KinectSensors.Count);
foreach (KinectSensor sensor in KinectSensor.KinectSensors)
if (sensor.Status == KinectStatus.Connected)
Console.WriteLine("Device Connection Id : {0} ", sensor.DeviceConnectionId.ToString());

This will show the number connected sensor and list of all the connected device.

List of Connected Kinect Sensor

Alternatively you can use simple LINQ statement to get list of the connected device and their connection Id as shown in below.

(from sensor in KinectSensor.KinectSensors where sensor.Status == KinectStatus.Connected select sensor.DeviceConnectionId)

You can also check the number of available Kinect sensor by reading the Count property of the KinectSensors collection – which we have discussed in one of our previous tip  and showed over here as well. – How to check if any Kinect device is connected with system ?

On a side note, If you are wondering, how to change the color in the console, you can easily do it using Console.ForegroundColor property.
As for example,

Console.ForegroundColor = ConsoleColor.Green;

One thought on “How to get list of all Connected Kinect Sensor ?

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

Comments are closed.