Skip to main content

Coding for Kinect for Xbox 360

Kinect is an amazing piece of technology. Not only for gaming, it can be used for variety of uses ranging from Healthcare, Security, IT etc. Starting with coding for Kinect seems daunting at first, mainly due to lack of knowledge and starting material.
This article documents my first attempt at coding for Kinect. So basically it’s a beginner level article which introduces us to Kinect. Before you begin, you must ensure that the following pre-requisites have been met.
After you install the Kinect for Windows SDK, plug-in your Kinect to your PC via the USB port and some device drivers should automatically get installed. Finally you should be able to see this screen.

Capture

Now that you have all set up, fire up Visual Studio and create a new WPF project. Add a reference to “Microsoft.Research.Kinect.dll” and “Coding4Fun.Kinect.Wpf.dll”. Next we will create a very basic application which captures Kinect’s RGB Video, Depth Video and try to create a Skeleton out of it. We will basically re-use the code from “Skeletal Viewer” sample that comes with Kinect for Windows SDK.


We will add two images to our XAML window to display the video streams. We will also add a Canvas to display the skeleton that we are tracking. Pretty simple!

<Window x:Class="MyFirstKinectApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" WindowState="Maximized" Loaded="Window_Loaded">
<Grid>
<Image x:Name="VideoFrameImage"
Height="500" Width="500" HorizontalAlignment="Left"
VerticalAlignment="Top"/>
<Canvas x:Name="SkeletalFrameImage"
Height="500" Width="500" HorizontalAlignment="Right"
VerticalAlignment="Top"/>
<Image x:Name="DepthFrameImage"
Height="500" Width="500" HorizontalAlignment="Left"
VerticalAlignment="Bottom"/>
</Grid>
</Window>

Coding4Fun dll helpfully add few extension methods which makes displaying the video streams a breeze. All we have to do is write:


VideoFrameImage.Source = e.ImageFrame.ToBitmapSource();

Next comes calculating and displaying the skeleton in the Canvas. You can follow the source code to see how it is actually being done.


Finally we end up with the following output:

vlcsnap-2011-10-22-19h33m10s33

That’s it! This is our sample sample application. As you move, the skeleton will mirror your movements. All we have to do now is to detect those movements and have some fun!

Comments

Popular posts from this blog

Integrating React with SonarQube using Azure DevOps Pipelines

In the world of automation, code quality is of paramount importance. SonarQube and Azure DevOps are two tools which solve this problem in a continuous and automated way. They play well for a majority of languages and frameworks. However, to make the integration work for React applications still remains a challenge. In this post we will explore how we can integrate a React application to SonarQube using Azure DevOps pipelines to continuously build and assess code quality. Creating the React Application Let's start at the beginning. We will use npx to create a Typescript based React app. Why Typescript? I find it easier to work and more maintainable owing to its strongly-typed behavior. You can very well follow this guide for jsx based applications too. We will use the fantastic Create-React-App (CRA) tool to create a React application called ' sonar-azuredevops-app '. > npx create-react-app sonar-azuredevops-app --template typescript Once the project creation is done, we

Use AI to build your house!

When a new housing society emerges, residents inevitably create chat groups to connect and share information using various chat apps like WhatsApp and Telegram. In India, Telegram seems to be the favorite as it provides generous group limits, admin tools, among other features. These virtual communities become treasure troves of invaluable insights. But whatever app you use, there is always a problem of finding the right information at right time. Sure, the apps have a "Search" button, but they are pretty much limited to keyword search and are useless when you have to search through thousands of messages. I found myself in this situation when it was my turn to start on an interior design project for my home. Despite being part of a vibrant Telegram group, where countless residents had shared their experiences with various interior designers and companies, I struggled to unearth the pearls of wisdom buried within the chat's depths. I remembered that I could take advantage o

Vaastu Shastra

There are certain tasks that the Indian society expects a person to fulfill - get a good job, get married at a certain age, buy a house, buy a car, have kids etc. So it would seem natural to you that after getting married I have started looking around for a house to buy. It isn't so. My hunt for a house began with a trip to the mall to buy a sofa set. It should not come as a surprise that I like movies. I have watched hundreds of movies and now that I have means at my disposal I started to improve my movie viewing experience. With TV and audio system out of the way, a comfy couch was all that was needed. So I dragged my wife with me to the mall and started evaluating the over-priced sofas. We hopped and jumped on a lot of them and when the dust finally settled, my heart was with a sofa that was also a recliner, rocking chair, had foot support, was made of high quality dead skin... err leather - the complete package! It also came with a hefty price tag. We came back home to di