none
KinectSensorChooserUI Help

    Question

  • Hello,

    I am trying to follow the 'quickstart' developer videos which are based on SDk 1.0 and 'adapt' it for SDK v1.5. However, I am facing a few issues.

    In more detail, I would like to ask how exactly do you use KinectSensorChooserUI in SDK 1.5 from the toolkit? I have looked at the Shape Game example from SDK 1.5 toolkit but don't quite understand how they incorporated it, and there is no 'quickstart' developer videos for SDk 1.5. The ones online are for SDk 1.0 and the beta, which don't have the KinectSensorChooserUI but rather KinectSensorChooser.

    Thanks in advance,

    Saturday, June 02, 2012 1:05 PM

Answers

  • The code and material provided in the QuickStart 1.0 tutorials are unchanged for 1.5. If you are having an issue with Kinect specific code, please let us know. If you are new to WPF, then you should ask over on the WPF forums.

    As for using the KinectChooser, this is no different than any other WPF user control. The general steps are simple enough (code behind in c#, but should be straight forward)

    1. In your project, add the Toolkit project or a reference to the .dll.
    2. add the namespace to your Xaml so that you can reference the controls in your markup. 
      xmlns:mskt="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit"
    3. add the control to your visual tree
      <mskt:KinectSensorChooserUI x:Name="SensorChooserUI" HorizontalAlignment="Center"VerticalAlignment="Center"/>
    4. From code behind, add the namespace, initialize its events and whatever else you need
      using Microsoft.Kinect;
      using Microsoft.Kinect.Toolkit;

      // local var
      private readonlyKinectSensorChoosersensorChooser = newKinectSensorChooser();

      // start the sensorChooser
      this.SensorChooserUI.KinectSensorChooser = sensorChooser;
      sensorChooser.Start();

    The rest is up to you. Remember, it isn't a requirement to use the controls and are there for your convenience. If they are too complex for your use, the code is provided so you can modify to meet your requirements.


    Tuesday, June 05, 2012 10:07 PM

All replies

  • you should look at the Kinect Explorer sample for a better reference.
    Saturday, June 02, 2012 9:47 PM
  • you should look at the Kinect Explorer sample for a better reference.

    But even in the Kinect Explorer sample it doesnt make use of KinectSensorChooserUI if am not mistaken.

    Taken from the MainWindow.xml

                    "<!-- IMPORTANT: KinectSensorChooserUI component in Microsoft.Kinect.Toolkit is better to use or copy from
                     than KinectExplorers user experience for device and discovery. -->"


    Ermos

    Sunday, June 03, 2012 10:47 AM
  • I have to agree Teh Owner -- any sort of assistance on using this would be helpful.  The SDK just says what Todd said - look at the Kinect Explorer sample for reference, but the example is complicated and tightly integrated, and not so easy to understand. 

    Also, I use VB - not C#, and there is no example - complex or simple - in the toolkit examples for using KinectSensorChooser/KinectSensorChooserUI with VB.

    Sunday, June 03, 2012 4:54 PM
  • The code and material provided in the QuickStart 1.0 tutorials are unchanged for 1.5. If you are having an issue with Kinect specific code, please let us know. If you are new to WPF, then you should ask over on the WPF forums.

    As for using the KinectChooser, this is no different than any other WPF user control. The general steps are simple enough (code behind in c#, but should be straight forward)

    1. In your project, add the Toolkit project or a reference to the .dll.
    2. add the namespace to your Xaml so that you can reference the controls in your markup. 
      xmlns:mskt="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit"
    3. add the control to your visual tree
      <mskt:KinectSensorChooserUI x:Name="SensorChooserUI" HorizontalAlignment="Center"VerticalAlignment="Center"/>
    4. From code behind, add the namespace, initialize its events and whatever else you need
      using Microsoft.Kinect;
      using Microsoft.Kinect.Toolkit;

      // local var
      private readonlyKinectSensorChoosersensorChooser = newKinectSensorChooser();

      // start the sensorChooser
      this.SensorChooserUI.KinectSensorChooser = sensorChooser;
      sensorChooser.Start();

    The rest is up to you. Remember, it isn't a requirement to use the controls and are there for your convenience. If they are too complex for your use, the code is provided so you can modify to meet your requirements.


    Tuesday, June 05, 2012 10:07 PM
  • If the v1 code doesn't have a kinect chooser control then modify version v1.5 kinect sdk's kinect chooser code.

    for kinect mouse the chooser control i believe it was used and to use with v1.5 i just readded the microsoft.kinect reference to be v1.5 reference and removed old v1 reference. Carmine is right their is no change between v1 and v1.5 except you need to rereference the new dll file for microsoft.kinect.


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://jefferycarlsonblog.blogspot.com/




    • Edited by The Thinker Thursday, June 07, 2012 1:52 PM
    Thursday, June 07, 2012 1:50 PM
  • I just know do it work!!

    Here is my code!

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Microsoft.Kinect;
    using Microsoft.Kinect.Toolkit;

    namespace Pureba1
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }

            KinectSensorChooser sensorChooser = new KinectSensorChooser();

            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                this.SensorChooserUI.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);

                KinectSensor newSensor = (KinectSensor)e.NewSensor;

                if (newSensor == null)
                {
                    return;
                }

                //register for event and enable Kinect sensor features you want
                newSensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(newSensor_AllFramesReady);
                newSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
                newSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
                newSensor.SkeletonStream.Enable();

                try
                {
                    newSensor.Start();
                }
                catch (System.IO.IOException)
                {
                    sensorChooser.TryResolveConflict();

                }
            }

            void newSensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
            {
                 //Here all the things you want to do
            }

            void StopKinect(KinectSensor sensor)
            {
                if (sensor != null)
                {
                    if (sensor.IsRunning)
                    {
                        sensor.Stop();
                        if (sensor.AudioSource != null)
                        {
                            sensor.AudioSource.Stop();
                        }
                    }
                }
            }

            void StopKinectSensorChooser(KinectSensorChooser sensorCh)
            {
                if (sensorCh != null)
                {
                    sensorCh.Stop();
                }
            }

            private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                StopKinect(sensorChooser.Kinect);
                StopKinectSensorChooser(sensorChooser);
            }
        }
    }

    • Proposed as answer by DrWaky Monday, June 11, 2012 10:38 AM
    Monday, June 11, 2012 10:38 AM
  • Here is that i do, and its wotrk to me to the QuickStart1.0 tutorials examples :)

    I hope that it was useful.  8)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Microsoft.Kinect;
    using Microsoft.Kinect.Toolkit;

    namespace Pureba1
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }

            KinectSensorChooser sensorChooser = new KinectSensorChooser();

            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                this.SensorChooserUI.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);

                KinectSensor newSensor = (KinectSensor)e.NewSensor;

                if (newSensor == null)
                {
                    return;
                }

                //register for event and enable Kinect sensor features you want
                newSensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(newSensor_AllFramesReady);
                newSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
                newSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
                newSensor.SkeletonStream.Enable();

                try
                {
                    newSensor.Start();
                }
                catch (System.IO.IOException)
                {
                    sensorChooser.TryResolveConflict();

                }
            }

            void newSensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
            {
                using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
                {
                    if (colorFrame == null)
                    {
                        return;
                    }
                    byte[] pixels = new byte[colorFrame.PixelDataLength];
                    colorFrame.CopyPixelDataTo(pixels);

                    int stride = colorFrame.Width * 4;
                    image1.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, pixels, stride);
                }
            }

            void StopKinect(KinectSensor sensor)
            {
                if (sensor != null)
                {
                    if (sensor.IsRunning)
                    {
                        sensor.Stop();
                        if (sensor.AudioSource != null)
                        {
                            sensor.AudioSource.Stop();
                        }
                    }
                }
            }

            void StopKinectSensorChooser(KinectSensorChooser sensorCh)
            {
                if (sensorCh != null)
                {
                    sensorCh.Stop();
                }
            }

            private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                StopKinect(sensorChooser.Kinect);
                StopKinectSensorChooser(sensorChooser);
            }
        }
    }

    • Proposed as answer by DrWaky Monday, June 11, 2012 10:40 AM
    Monday, June 11, 2012 10:40 AM
  • Hey guys! So I was having the same issues as everybody seems to be having when it comes to the kinectSensorChooser on V.1.5. It seems as though when you are referencing the WPFViewers, you actually need to download the Quickstart Samples located here: http://channel9.msdn.com/Series/KinectQuickstart/Setting-up-your-Development-Environment

    Extract the files and the WPFViewers file that you need to reference is located here, which will have sensorChooser. If you use the WPFViewers reference from the KinectExplorer, it will not include the sensorChooser. Also, make sure to reference the toolkit as well. 

    Hope this helps! :)

    Tuesday, June 12, 2012 7:10 PM