문제

This should be pretty simple, but a quick Google didn't turn up anything useful and I don't see any members on Microsoft.Kinect.KinectSensor that look helpful.

I'm writing an application that uses a Kinect for some gesture control stuff. It works fine with either the Xbox or PC version of the Kinect, but the Xbox version doesn't support "near mode", so the user has to be a certain distance back. I'd like to let the user know this when they launch the program.

Is it possible to detect which version of the Kinect has been connected? I get a message in Visual Studio's debug output telling me that I've connected an Xbox version, so it must be checking somewhere, but I don't see anywhere that this information is made available to my code.

도움이 되었습니까?

해결책

When you try to use a feature that the Xbox version does not support, an InvalidOperation is thrown. When you catch that exception, you can be sure that a Xbox kinect is connected.

 try
 {
   sensor.DepthStream.Range = DepthRange.Near;
   sensor.SkeletonStream.EnableTrackingInNearRange = true;
 }
 catch (InvalidOperationException)
 {
   // Non Kinect for Windows devices do not support Near mode, so reset back to default mode.
   sensor.DepthStream.Range = DepthRange.Default;
   sensor.SkeletonStream.EnableTrackingInNearRange = false;
 }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top