0

I am writing my first Kinect Application with the following user interface. Kinect User Interface

I am following this tutorial for more context.

The concept of the application consists only to integrate the camera of the Kinect into the desktop application. I think it might be important to note that I have a Kinect for Xbox One and its corresponding adapter using the Kinect SDK and Toolkit Version 1.8

The code for the button event handling is the following is the following

    private void btnStream_Click(object sender, EventArgs e)
    {
        if (btnStream.Text == "Stream")
        {
           
            if (KinectSensor.KinectSensors.Count > 0)
            {
               
                ksensor = KinectSensor.KinectSensors[0];
                KinectSensor.KinectSensors.StatusChanged += KinectSensors_StatusChanged;
                
            }
            ksensor.Start();
            lblConnectionID.Text = ksensor.DeviceConnectionId;

        }
        else
        {
            if (ksensor != null && ksensor.IsRunning)
            {
                ksensor.Stop();
                this.btnStream.Text = "Stream";
                this.pbStream.Image = null;
            }
        }

    }

    private void KinectSensors_StatusChanged(object sender, StatusChangedEventArgs e)
    {
        this.lblStatus.Text = ksensor.Status.ToString(); 
    }

and I get the following error from Visual Studio

An unhandled exception of type 'System.NullReferenceException' occurred in WindowsFormsApplication1.exe

Additional information: Object reference not set to an instance of an object.

The error is pointing to this line of code:

ksensor.Start();

It is guaranteed that the ksensor variable is declared as follows:

private KinectSensor ksensor;

My question is why is my variable KinectSensor.KinectSensors.Count probably 0 while I am supposed to have 1 as the return value? Does my application not recognize my kinnect?

Community
  • 1
  • 1
user1680944
  • 537
  • 2
  • 13
  • 23

1 Answers1

1

I think it might be important to note that I have a Kinect for Xbox One and its corresponding adapter using the Kinect SDK and Toolkit Version 1.8

The problem is that Microsoft Kinect SDK 1.8 is not compliant with Kinect for Xbox One (see this link).

You should install Kinect SDK 2.0 instead (download is available at this link). Or if you want to follow that tutorial with Kinect SDK 1.8, you should buy an old Kinect for Xbox 360.

Vito Gentile
  • 13,336
  • 9
  • 61
  • 96
  • I thought that the functions implemented in the Kinect SDK 2.0 are the same as the Kinect SDK 1.8 plus the new ones that support the hardware improvement for the Kinect of the XBOX ONE, but I figured out that it is not the case is that right? – user1680944 Apr 11 '16 at 00:05
  • Right. SDK 1.x and SDK 2.0 are quite different actually. – Vito Gentile Apr 11 '16 at 07:14