Back to basics with a Basic XNA and Kinect SDK sample
- Posted: Aug 17, 2011 at 6:00 AM
- 7,996 Views
- 1 Comment
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Every so often it's good to take a step back and review some basics, to look at something a little less complex, to revel in simplicity. That and I liked how this sample used XNA...
BTW, no this isn't a Windows Phone related sample in any way, but I recent received that WP7 Foam Guy and I had major bed head, so... ![]()
This past week I have spent a little bit of time playing with the Kinect SDK and trying to get to grips with how it all works. My biggest interest is to use the Kinect SDK along with Microsoft’s XNA Framework for games development so I made a sample project using these technologies. I’ve posted a link to this project at the end of the article.
The idea of this project was pretty simple. I wanted to get the RGB camera stream of me goofing around and use it as the background in an XNA application. I also wanted to try out some skeleton tracking functionality to test when my hands are intersecting with hot spots (represented as semi-transparent squares) on the screen. As it turns out, this project was pretty simple and quick to make and overall I’m really quite impressed with how the SDK is to use.
This project makes use of a couple of simple extension methods I created and ...
Project Information URL: http://jason-mitchell.com/2011/06/28/basic-xna-and-kinect-sdk-sample/
Project Source URL: http://jason-mitchell.com/Uploads/XNA_And_Kinect-28_06_11.zip
private void SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
SkeletonFrame skeletonFrame = e.SkeletonFrame;
ResetSquareColors();
foreach (SkeletonData data in skeletonFrame.Skeletons)
{
if (data.TrackingState == SkeletonTrackingState.PositionOnly)
{
foreach (Joint joint in data.Joints)
{
if (joint.ID == JointID.HandRight || joint.ID == JointID.HandLeft)
{
Vector2 jointPosition = joint.GetScreenPosition(kinectRuntime, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
Rectangle rectangle = new Rectangle((int)jointPosition.X - (JointIntersectionSize / 2), (int)jointPosition.Y - (JointIntersectionSize / 2), JointIntersectionSize, JointIntersectionSize);
foreach (TextureInstance texture in hotSpots)
{
if (texture.CalculateBoundingRectangle().Intersects(rectangle))
texture.Color = Color.LimeGreen;
}
}
}
}
}
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
kinectRGBVideo.Draw(spriteBatch);
foreach (TextureInstance texture in hotSpots)
texture.Draw(spriteBatch);
spriteBatch.End();
base.Draw(gameTime);
}Contact Information:
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
cool man
Remove this comment
Remove this thread
close