How to get list of all Connected Kinect Sensor ?

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;
Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

One Comment to “How to get list of all Connected Kinect Sensor ?”

Comments are closed.