2014年4月5日 星期六

Kinect 1.8 Interaction

Hardware: ASUS X450J, XBOX360
OS: Windows 8.1
Tools: VS2012 + Kinect SDK1.8
1) Prepare
    KinectInteraction180_32.dll
    KinectInteraction180_64.dll
    Microsoft.Kinect.Toolkit.Controls.dll
   Microsoft.Kinect.Toolkit.Interaction.dll
2) Add Ref:
    Microsoft.Kinect (1.8)
   Microsoft.Kinect.Toolkit.Controls.dll
   Microsoft.Kinect.Toolkit.Interaction.dll
3) Add Existed items
    KinectInteraction180_32.dll
    KinectInteraction180_64.dll
4) xaml
<Window x:Class="WPFS1.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/2013"
        Title="MainWindow" Height="350" Width="525"
        Closing="WindowClosing">
    <Grid>
        <k:KinectUserViewer k:KinectRegion.KinectRegion="{Binding ElementName=kinectRegion}" Height="100" HorizontalAlignment="Center" VerticalAlignment="Top" />
        <k:KinectSensorChooserUI HorizontalAlignment="Center" VerticalAlignment="Top" Name="sensorChooserUi" />
        <k:KinectRegion x:Name="kinectRegion">
            <k:KinectTileButton Label="Press Me" Click="KinectTileButton_Click" />
        </k:KinectRegion>
    </Grid>
</Window>
   5) C#
 public MainWindow()
        {
            InitializeComponent();
            this.sensorChooser = new KinectSensorChooser();
            this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
            this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
            this.sensorChooser.Start();

            // Bind the sensor chooser's current sensor to the KinectRegion
            var regionSensorBinding = new Binding("Kinect") { Source = this.sensorChooser };
            BindingOperations.SetBinding(this.kinectRegion, KinectRegion.KinectSensorProperty, regionSensorBinding);
        }
 private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            this.sensorChooser.Stop();
        }

        private void KinectTileButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.Title != "Press")
            {
                this.Title = "Press";
            }
            else
            {
                this.Title = "Again?";
            }
        }
6) 下載(請自行加入KinectInteraction180_32 and _64.dll files)

沒有留言:

張貼留言