Exemplo n.º 1
0
 //Activates colour stream when this button is clicked.
 private void ColourStreamClick(object sender, RoutedEventArgs e)
 {
     if (null == this.sensor)
     {
         this.statusBarText.Text = noKinectReady;
     }
     else
     {
         ColourStream colourStream = new ColourStream();
         Image.Source       = colourStream.StartColourStream(sensor);
         Button0.Background = Brushes.Gray;
         Button1.Background = new SolidColorBrush(Color.FromRgb(110, 8, 178));
         Button2.Background = new SolidColorBrush(Color.FromRgb(110, 8, 178));
     }
 }
Exemplo n.º 2
0
        //Checks for Kinect sensor, activates colour stream. Populates grammar with the
        //word "finish" to trigger finish button.
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {
                    this.sensor = potentialSensor;
                    break;
                }
            }

            if (null != this.sensor)
            {
                ColourStream colourStream = new ColourStream();
                Image.Source       = colourStream.StartColourStream(sensor);
                Button0.Background = Brushes.Gray;
                this.sensor.DepthStream.Enable();
                this.sensor.SkeletonStream.Enable();

                RecognizerInfo ri = GetKinectRecognizer();
                if (null != ri)
                {
                    this.speechEngine = new SpeechRecognitionEngine(ri.Id);
                }
                var gb = new GrammarBuilder {
                    Culture = ri.Culture
                };
                gb.Append("finish");

                var g = new Grammar(gb);
                speechEngine.LoadGrammar(g);
                speechEngine.SpeechRecognized += SpeechRecognized;

                speechEngine.SetInputToAudioStream(
                    sensor.AudioSource.Start(), new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));

                speechEngine.RecognizeAsync(RecognizeMode.Single);

                sensor.AllFramesReady += SensorAllFramesReady;
            }

            if (null == this.sensor)
            {
                this.statusBarText.Text = noKinectReady;
            }
        }