none
no constructor defined for KinectSensor, so I cannot create an Instance RRS feed

  • Question

  • Hello,

    I was trying to write a very simple program that only writes the joint-position data on the console. In general I followed the HowTo from the documetation of the Kinect SDK (skeleton C# HowTo) und some Videos of Channel9:

    http://channel9.msdn.com/Series/KinectSDKQuickstarts/Skeletal-Tracking-Fundamentals , for example

    But now I have an error, when I want to instanciate the KinectSensor class:

           KinectSensor kinectSensor = new KinectSensor();

    Visual Studio says, there are no constructors defined. But I think I need the instance, because otherwise I couldnt execute the following code, also from the SDK documentation:

    kinectSensor.SkeletonStream.Enable();

    kinectSensor.Start();

    And in the videos this instanciation is also shown. So what have I done wrong?

    I have the current SDK (version 1.0), I have added the reference Microsoft.Kinect and I have added the using Microsoft.Kinect statement.

    ...Or does anyone know a tutorial, that REALLY works (with current SDK)?

    Thank you for answers!

    Tuesday, May 1, 2012 8:28 PM

Answers

  • The videos are based on a beta release of the Kinect for Windows SDK. Here's a simple way to do it with the 1.0 release:

    using System.Linq;
    ...
    kinectSensor = KinectSensor.KinectSensors.Where(s => s.Status == KinectStatus.Connected).FirstOrDefault();

    KinectSensor.KinectSensors is a collection of all Kinect devices currently detected by your computer. If the collection is empty (no Kinect devices currently plugged in), this statement will set kinectSensor to null, so you should check that the value is not null before using it.

    John
    K4W Dev

    • Marked as answer by SealedClass Wednesday, May 2, 2012 8:14 AM
    Wednesday, May 2, 2012 7:25 AM

All replies

  • The videos are based on a beta release of the Kinect for Windows SDK. Here's a simple way to do it with the 1.0 release:

    using System.Linq;
    ...
    kinectSensor = KinectSensor.KinectSensors.Where(s => s.Status == KinectStatus.Connected).FirstOrDefault();

    KinectSensor.KinectSensors is a collection of all Kinect devices currently detected by your computer. If the collection is empty (no Kinect devices currently plugged in), this statement will set kinectSensor to null, so you should check that the value is not null before using it.

    John
    K4W Dev

    • Marked as answer by SealedClass Wednesday, May 2, 2012 8:14 AM
    Wednesday, May 2, 2012 7:25 AM
  • Thank You SO much, it works!

    BTW, I better had looked in the "Programming Guide" of the documentation, there is some code similar to yours :)

    Wednesday, May 2, 2012 8:14 AM