Hand detection (cursor) within Kinect Region not working in new project

1.7k Views Asked by At

I have a two extremely simple Kinect for Windows projects.

One project is based on the original Kinect for Windows development SDK V2 code sample titled ControlsBasics-WPF (available in the V2 SDK browser) and another which was created from scratch via a new project and subsequently referencing the Kinect SDK through nuget package manager.

The code in both projects amounts to the following XAML.

<kinectTools:KinectRegion x:Name="kinectRegion">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="2*" />
            <RowDefinition Height="8*" />
        </Grid.RowDefinitions>
        <kinectTools:KinectUserViewer Grid.Row="0" />


    </Grid>
</kinectTools:KinectRegion>

and the following C#

public MainWindow()
{
    InitializeComponent();
    KinectRegion.SetKinectRegion(this, kinectRegion);
    this.kinectRegion.KinectSensor = KinectSensor.GetDefault();
}

If I run the project the expected behavior is that once an arm (left or right) is raised a cursor should appear onscreen within the defined KinectRegion area.

However while the version based on the ControlsBasics-WPF sample code is rock solid and behaves exactly as expected (with the cursor appearing and tracking) almost immediately. The version based on a new project exhibits intermittent behavior where very rarely the cursor appears on-screen.

Please find the following two solutions which demonstrate the problem:

  1. Working Detection
  2. Broken Detection

Also note that I have deliberately removed the dll references from the SDK code sample version and used nuget to reference the SDK to ensure the same libraries were referenced and this did not affect the behavior. The code within the two project is (as best as I can tell) identical but obviously I am missing something.

Any input would be immensely appreciated!

1

There are 1 best solutions below

0
GeoLeo On

All what you need to make a kinect supported WPF Program is:

1- create a new WPF program. 2- Add the references "Microsoft.Kinect" & "Microsoft.Kinect.Wpf.Controls". 3- Add this line to the Window object in your xaml page. xmlns:k="http://schemas.microsoft.com/kinect/2014"

And finally just create a kinect region object, maybe add a button within it. something like:

{

<k:KinectRegion x:Name="kinectRegion">
<Grid>
<Button Content="sdfsdfdsfsdfsdf" Background="#FF2F55A6" BorderThickness="6"  Width="150" Height="50" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Grid>
</k:KinectRegion>

}

When you run your project you should be able to see the hand cursor, and to press the button that you have just created. All with one xaml page only. that looks identical to this:

<Window x:Class="KinectDynamicAppLive.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:k="http://schemas.microsoft.com/kinect/2014"
        Title="MainWindow" Height="350" Width="525">
    <k:KinectRegion x:Name="kinectRegion">
    <Grid>
            <Button Content="sdfsdfdsfsdfsdf" Background="#FF2F55A6" BorderThickness="6"  Width="150" Height="50" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

        </Grid>
      </k:KinectRegion>
</Window>