Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!
.NET Zone is brought to you in partnership with:

Den works on awesome stuff. He is a sophomore in college, a Microsoft MVP, a Microsoft Student Insider, a technical writer for DZone and a contributing author for Coding4Fun on Channel9. He is maintaining a number of open-source projects on CodePlex and GitHub. Den is a DZone Zone Leader and has posted 388 posts at DZone. You can read more from them at their website. View Full User Profile

KinectContrib 2.0 released - now supports Kinect for Windows SDK 1.0

02.08.2012
Email
Views: 2104
  • submit to reddit
The .NET Zone is presented by JNBridge to keep you updated on all the latest news, tips, and tools in the .NET community.  Check out today's top .NET content and read about JNBridge's innovative tools for .NET and Java interoperability.  

KinectContrib is a project I started, trying to extend the capabilities of the default Kinect for Windows SDK. As I am working on more complex components, I decided that it would be easier to start with something a lot of developers will need - Visual Studio templates that provide the skeleton for basic Kinect application types.

I worked last night and today to finally make the project compatible with the new Kinect for Windows SDK, that recently hit version 1.0. There were many breaking changes that required me to refactor large chunks of code. At the end of the day, it is all working as it should. You can download the bits by following the links below.

As usual, you can download the source code here:

The current template set includes projects for C#, VB .NET and F#.

Speaking of which, I had some interesting moments while building the F# part. With the new SDK, the image is no longer returned as a separate entity but rather as a byte array. This requires me to handle array resizing in C# and VB.NET - not that big of a problem for an experienced developer. But I haven't had a chance to work a lot with F#, so that's when I found out that Array.Resize might not be the perfect choice.

Take a look at these fragments:

let ds : byte = Convert.ToByte(1)
let dummySkeleton : Skeleton = new Skeleton(TrackingState = SkeletonTrackingState.Tracked)

// Thanks to Richard Minerich (@rickasaurus) for helping me figure out
// some array concepts in F#.
let mutable pixelData : byte array = [| |]
let mutable skeletons : Skeleton array = [| |]

Initially, I didn't think of these arrays as mutable. So I tried directly resizing them to no avail. Later, Richard Minerich, a F# MVP, suggested that I re-create the array instead. So in the re-initialization parts of the code, I used something like this:

pixelData <- Array.create r.PixelDataLength ds

This solved one problem, but I had to jump yet another hoop. As I was testing the C# "harness", I noticed that I can get a tracked skeleton while I am sitting in a chair - the camera sees me from waist up. This was good, however, when I tried to test the same code translated to F#, the skeleton tracking was not working. As it turns out, for an unknown (at the moment) reason, the F# application reacts in a weird way to a waist-up user position, not seeing the skeleton. Once I stand up, so the camera caught my full height, everything works fine.

This should not generally affect performance and can be considered a potential SDK/hardware limitation.

PS: The released templates should also be compatible with the Kinect for Windows sensor.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

This content was brought to you in partnership with JNBridge.  JNBridge specializes in .NET and Java interoperability.  Be sure to view JNBridge's brief video series on accessing Java from .NET.