Kinect for Windows SDK + XNA

Posted November 21, 2011 1:13 PM Categories: .NET | C# | Kinect | XNA

imageI have seen a few people talk about using the Kinect for Windows SDK with XNA lately, and many of those projects aren't using the SDK how it's intended to be used from a framework such as this.

When I had a hand in working on the managed SDK, I made a point that the API should allow for both an "eventing" model, and a polling model.  In the land of WPF and WinForms, an eventing model makes perfect sense.  In these frameworks, the SDK is intended to be used thusly:

private Nui.Runtime _kinect = Nui.Runtime.Kinects[0];

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    _kinect.DepthFrameReady += DepthFrameReady;
    _kinect.SkeletonFrameReady += SkeletonFrameReady;
}

void DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
{
    // do something with the depth frame
}

void SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
    // do something with the skeleton frame
}

But, in the land of XNA, where all of your code is shared between the Update and Draw methods, and where events don't really exist in the normal flow of things, trying to synchronize the Kinect events and the data they provide with the Update and Draw loop can be difficult, and can lead to conditions where data is being updated from an event while you're touching it in the Update method.  Sure, you could use locks to help synchronize things, but there's an easier way.

To help with this, the API contains methods to directly poll for the latest data, such as the current depth frame or skeleton frame.  These methods can be used as shown:

private Runtime _kinect = Runtime.Kinects[0];
private SkeletonFrame _skeletonFrame;
private ImageFrame _depthFrame;

protected override void Update(GameTime gameTime)
{
    _skeletonFrame = _kinect.SkeletonEngine.GetNextFrame(0);
    _depthFrame = _kinect.DepthStream.GetNextFrame(0);

    base.Update(gameTime);
}

protected override void Draw(GameTime gameTime)
{
    // do something with _skeletonFrame and/or _depthFrame
    // such as, draw it to the screen
    
    base.Draw(gameTime);
}

So, if you're using XNA in tandem with the Kinect for Windows SDK, be sure to use the API as it was intended.  It will likely save you some debugging headaches later on.

Kinect for Windows SDK is here!

Posted June 16, 2011 12:47 PM Categories: Gaming | .NET | Coding4Fun | Hardware | C/C++ | C# | NUI | Kinect

image

Hooray!  I can finally talk about this!  As I've alluded to previously, I had a hand (one of many) in the managed portion of the SDK and what was originally shown at MIX. Since then the SDK has changed a bit but it's finally ready to go!

The Kinect for Windows SDK is now available for download on the Microsoft Research site.  We have also launched several samples over at Coding4Fun that you can begin using immediately:

Coding4Fun Kinect Toolkit

You definitely want to download this one when you get started.  This toolkit contains a variety of extension methods and controls to make using the Kinect for Windows SDK even easier to use.  Some of my code appears in this one.  Smile

Kinect Mouse Cursor

This sample is entirely mine.  Kinect Mouse Cursor is a demo application that uses the Kinect for Windows SDK and its skeletal tracking features to allow a user to use their hands to control the Windows mouse cursor.  Use your right hand to move the cursor, and raise your left hand to press the left mouse button.  Use the check box to switch hands…
image

Kinect Paint

Kinect Paint is a skeleton tracking application that allows you to become the paint brush!  IdentityMine built this for us.

imageimageimage

imageimage

Kinect for Windows SDK Quickstarts

This is a series of quick start videos starring the lovely and talented Dan Fernandez, who walks you through the basics of Kinect development from the very beginning.  Don't miss these!

Coding4Fun's Kinect for Windows SDK Blog

Add a bookmark to this now.  Coding4Fun will be tracking awesome projects using the new SDK here.  Have something to show off?  Tell us!

Kinect Hack-a-thon

In coordination with the Kinect launch, developers were invited out to the Microsoft campus to develop applications in a 24 hour "code-a-thon".  Some health issues prevented me from attending this event, but I'm looking forward to seeing what these people came up with…

We will have more samples and fun projects at Coding4Fun soon, so be sure to check back there (and here) regularly for more Kinect goodness.  Until then, enjoy the new SDK, our new samples, and see what you can build!  I'd love to hear about any projects you create with these tools…

MJPEG Decoder v1.1

Posted May 8, 2011 1:25 AM Categories: C# | Coding4Fun | MJPEG | Silverlight | Windows Phone | WPF | XNA

A quick update to my Motion JPEG Decoder is now available at CodePlex.  Version 1.1 adds the ability to specify username/password credentials for cameras that require a login.  For example:

MjpegDecoder _mjpeg;

_mjpeg = new MjpegDecoder();
_mjpeg.FrameReady += mjpeg_FrameReady;

_mjpeg.ParseStream(new Uri("http://192.168.2.200/img/video.mjpeg"), "user", "password");

As always, questions/comments welcome.  Enjoy!

TweeVo v1.1 Released!

Posted October 14, 2010 6:07 AM Categories: .NET | Coding4Fun | Twitter | TweeVo | C#

A new version of TweeVo is finally available.  This version allows the program to work once again now that Twitter has switched over to a mandatory OAuth/xAuth authentication scheme.  Chris Miller deserves all the credit for this one for handling the implementation of the new security scheme with some sample code from Shannon Whitley.  You can find downloads over on the original TweeVo page.  Give it a try and let me know if you run into any issues making it go.  Enjoy!

ThinkGearNET 1.1

Posted August 16, 2010 4:25 AM Categories: .NET | Coding4Fun | Hardware | Neurosky MindSet | C#

imageI released version 1.1 of ThinkGearNET over at CodePlex last week.  ThinkGearNET is a library that allows developers to easily use the Neurosky MindSet device with .NET.  This version now matches Neurosky’s latest SDK and supports eye blink detection.  Nothing else has changed.  If anyone has used a prior version of the library, please give the new version a try and let me know if you have any problems.  Thanks!

My Info

  • View Brian Peek's profile on LinkedIn

Sponsored Ad

My Book

Sponsored Ad

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar