[# KINECT] HowTo: Detect the change of State of the sensor Kinect

image

Hi,

now that we already have the Beta 2 Kinect for Windows SDK in our hands, because we see as detected when you connect or disconnect a Kinect sensor to our computer.

Tutorial

1 Create an implementation of the WPF Application type

2 Add the following references

  • Microsoft.research.Kinect
    < % Program Files % > \Microsoft SDKs\Kinect\v1.0 Beta2\Assemblies\Microsoft.Research.Kinect.dll

3. Then we modify our MainWindow to initialize the capture of events in the Load of the Window.

  1: <Window x:Class=”ElBruno.KinectStatus.MainWindow”

  2: xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;

3: xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;

4: Title=”MainWindow” Height=”350″ Width=”525″ Loaded=”WindowLoaded”>

5: <Grid>

6:

7: </Grid>

8: </Window>

 

4 Implement the WindowLoad() event and in the same we subscribe to the change of State that fires when you connect one or more sensors Kinect.

   1: using System.Windows;

2: using Microsoft.Research.Kinect.Nui;

3: 

4: namespace ElBruno.KinectStatus

5: {

6: public partial class MainWindow : Window

7: {

8: public MainWindow()

9: {

10: InitializeComponent();

11: }

12: 

13: private void WindowLoaded(object sender, RoutedEventArgs e)

14: {

15: Runtime.Kinects.StatusChanged += KinectsStatusChanged;

16: }

17: 

18: private void KinectsStatusChanged(object sender, StatusChangedEventArgs e)

19: {

20: MessageBox.Show(e.Status.ToString());

21: }

22: }

23: }

 

5. At this point already, we can compile and run our application. After connecting and disconnecting the device several times we see something similar to the following

image

More easy impossible right? Risa

keep playing…

 

Greetings @ Home

The Bruno

  

Advertisements

One thought on “[# KINECT] HowTo: Detect the change of State of the sensor Kinect”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.