Today I'll speak about the migration from Kinect SDK 1.0 to SDK 1.5 . It was mostly easy, but there are some non very clear things that made me spent more time that I wanted:
- When you're working with a WPF application, sometimes you must modify the XAML archive. The KinectSensorChooser tool has changed the way of access if you want to upgrade; so if you have something like that:
<Window x:Class="MyProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="522" Width="897" Loaded="Window_Loaded" xmlns:myNameSpace="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers" Closing="Window_Closing" Name="RecognizerMainWindow">
<Grid>
<myNameSpace:KinectSensorChooser HorizontalAlignment="Left" Margin="326,59,0,0" Name="kinectSensorChooser1" VerticalAlignment="Top" Width="340" Height="240" />
...
you must change the XML namespace and the reference for the chooser in that way for the SDK 1.5:
<Window x:Class="MyProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="522" Width="897" Loaded="Window_Loaded" xmlns:my="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit" Closing="Window_Closing" Name="RecognizerMainWindow">
<Grid>
<my:KinectSensorChooserUI HorizontalAlignment="Left" Margin="538,243,0,0" Name="kinectSensorChooserUI" VerticalAlignment="Top" Width="99" Height="40" KinectSensorChooser="{Binding ElementName=kinectSensorChooser1, Path=KinectSensorChooser.KinectSensorChooser}" />
so, just change the property and the reference: from Microsoft.Samples.Kinect.WpfViewers to Microsoft.Kinect.Toolkit, and therefore the inner field.
- Now, in the application code, it has changed also the way of declare the Kinect Sensor, before it was a DependencyPropertyChanged event as:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
kinectSensorChooser1.KinectSensorChanged += new DependencyPropertyChangedEventHandler(kinectSensorChooser1_KinectSensorChanged);
}
void kinectSensorChooser1_KinectSensorChanged(object sender, DependencyPropertyChangedEventArgs e)
{
KinectSensor oldSensor = (KinectSensor)e.OldValue;
StopKinect(oldSensor);
KinectSensor newSensor = (KinectSensor)e.NewValue;
}
but now, you must declare it as follows:
KinectSensorChooser sensorChooser = new KinectSensorChooser();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.kinectSensorChooserUI.KinectSensorChooser = sensorChooser;
sensorChooser.KinectChanged += new EventHandler<KinectChangedEventArgs>(sensorChooser_KinectChanged);
sensorChooser.Start();
}
void sensorChooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
KinectSensor oldSensor = (KinectSensor)e.OldSensor;
StopKinect(oldSensor);
newSensor = (KinectSensor)e.NewSensor;
}
And that's all folks!! hope that you migration would be less traumatic with these hints (=
Lotta love at the garden,
JuananRey.