Kinect: Getting Started

Microsoft released its Kinect SDK yesterday. It can be found here. I spent yesterday afternoon building my own sample application to explore the API and Microsoft’s samples.

The API documentation is fairly comprehensive and the getting started guide is a quick read (on the Kinect SDK website, not included in the download). The two samples are large and cover all the major points of the API. I think I would have preferred smaller, more targeted samples, but they are still good for figuring out how to use pieces of the API.

The Kinect hardware does quite a bit of processing, so the API is fairly easy to work with. Pulling color image data off of the device is almost trivial:

var kinect = new Runtime();

kinect.Initialize(RuntimeOptions.UseColor);

 

kinect.VideoStream.Open(ImageStreamType.Video,

   2, ImageResolution.Resolution640x480, ImageType.Color);

 

kinect.VideoFrameReady += HandleNewColorVideoFrame;

This is all the code needed to start receiving video from the Kinect. Every time there is a new frame available the “HandleNewColorVideoFrame” method will get called. The EventArgs has a property that contains the image data of the new frame.

The really revolutionary part of the Kinect is the depth map it provides of the scene it can see. For each frame of the depth map video it can create detailed skeletal information about two people in the scene. This skeletal information gives the (X, Y, Z) absolute position of 20 points on the body and the confidence of that absolute position. The confidence is mostly for points that the Kinect cannot directly see. For example, the Kinect will still try to track my hand if I put it behind my back. It is just as easy to get the skeletal data as it is to get the color video image:

kinect = new Runtime();

kinect.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | 

   RuntimeOptions.UseSkeletalTracking);

 

kinect.DepthStream.Open(ImageStreamType.Depth, 2,

  ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);

 

kinect.SkeletonFrameReady += ProcessSkeletonFrame;

ProcessSkeletonFrame will be called every time the Depth video has a new frame. The EventArgs contains a list of all of the skeletons the Kinect has information about.

This is all the code you need to get up and running with a Kinect. It’s pretty awesome that it takes so little to start working with it; however, working with it is by no means easy. There are a lot of considerations that need to be made to make the Kinect a good user experience. In my next post I will go over a couple gotchas that I encountered while building my sample.

This entry was posted in .Net, Kinect. Bookmark the permalink.