且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在同一个应用中查看多个Kinect设备

更新时间:2023-11-22 16:35:34

您需要一组KinectSensor对象。现在你的代码只设置第一个传感器,然后打破循环。您需要修改多个传感器的帐户,因为this.sensor无效。另请注意,
如果有其他正在运行的应用程序,该传感器将不会出现在您的收藏中。

 this.sensorCollection = new List< KinectSensor> (); 

foreach(kinectSensor.KinectSensors中的var potentialSensor)
{
if(potentialSensor.Status == KinectStatus.Connected)
{
try
{
//尝试开始,如果我们不能使用它,请尝试另一个
potentialSensor.Start();
this.sensorCollection.Add(potentialSensor);
}
catch(System.IO.IOException)//由KinectSensorStart抛出()
{
continue;
}

}

如果需要更多代码,可以从SDK工具包中查看Kinect Explorer示例。


Hello, i have some experiencie with programming for Kinect in Kinect SDK v1 .

I have 4 kinects here and im trying to work with then at the same time in the SAME window.

I already messed with skeleton and depth streams using one kinect per executable, i would start 4 instances of my application separately, using the following code:

               
 
 foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {

                    try
                    {
                        // try to start, if we can't it is in use, try another one
                        potentialSensor.Start();                  
                        this.sensor = potentialSensor;
                        break;
                    }
                    catch (System.IO.IOException) // thrown by KinectSensorStart()
                    {
                        continue;
                    }

                }
            }

But now i want to view all kinects in the same window (executable).

I ve only found one code that does this, but its in a old version (beta) of the SDK, and i cant manage to port it. 

The code is here, its too big to put here.

http://abhijitjana.net/2011/09/23/development-with-kinect-net-sdk-part-v-developing-application-using-multiple-kinect-devices/

Any help?

PS: I have no problem with USB bus, i ve bought usb controllers for that, and i can see 4 kinects with the kinect explorer sample.

You need a collection of KinectSensor objects. Right now your code only sets the first sensor only and then breaks the loop. You need to modify what you have to account for multiple sensors though, since this.sensor will not be valid. Also take note, if there are other application that are running that sensor will not appear in your collection.

this.sensorCollection = new List<KinectSensor>();

foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {
                    try
                    {
                        // try to start, if we can't it is in use, try another one
                        potentialSensor.Start();                  
                        this.sensorCollection.Add(potentialSensor);
                    }
                    catch (System.IO.IOException) // thrown by KinectSensorStart()
                    {
                        continue;
                    }

                }

You can review the Kinect Explorer sample from the SDK toolkit if you need more code.