none
Difficulties starting Kinect programming in Visual Studio 2013 RRS feed

  • Question

  • I am trying to learn how to program with the kinect in c# so purchased a book called: 'beginning Kinect programming with the Microsoft Kinect SDK'. This is for my 3rd year independent project where i need to track and manipulate skeletal data.

    unfortunately the first example does not build and I do not know enough about c# to debug it. here is the code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.Kinect;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                //instantiate the sensor
                KinectSensor sensor = KinectSensor.KinectSensors[0];
    
                //initialise the cameras
                sensor.DepthStream.Enable();
                sensor.DepthFrameReady += sensor_DepthFrameReady;
    
                //make it look like the matrix
                Console.ForegroundColor = ConsoleColor.Green;
    
                //start the data streaming
                sensor.Start();
                while (Console.ReadKey().Key != ConsoleKey.Spacebar) { }
            }
    
            static void sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e);
            {
                 using ( var depthFrame = e.OpenDepthImageFrame());
                 {
                    if(depthFrame == null)
                        return;
                    short[] bits = new short [depthFrame.PixelDataLength];
                    depthFrame.CopyPixelDataTo(bits);
                    foreach (var bit in bits)
                        Console.Write(bit);
        }
        }
        }
    }

    If anybody could help to get me started that would be great, i will continue independently learning c# in the mean time and will keep trying

    kind regards

    Monday, December 30, 2013 2:29 PM

Answers