private void Initialize()
        {
            if (kinectRuntime == null)
                return;

            kinectRuntime.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
            kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
            kinectRuntime.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(kinectRuntime_VideoFrameReady);
            kinectRuntime.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinectRuntime_SkeletonFrameReady);
            skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, kinectCanvas);

            gestureRecognizer.TraceTo(gesturesCanvas, System.Windows.Media.Color.FromRgb(255, 0, 0));
            gestureRecognizer.OnGestureDetected += new Action<string>(OnGestureDetected);
            gestureRecognizer.MinimalPeriodBetweenGestures = 2000;
        }
        //Initialize method is called when a Kinect sensor is connected
        private void Initialize()
        {
            if (kinectSensor == null)
                return;
            //The beam angle is simply displayed by the AudioStreamManager:
            audioManager = new AudioStreamManager(kinectSensor.AudioSource);
            audioBeamAngle.DataContext = audioManager;

            kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady;
            kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
            kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady;
            kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters
            {
                Smoothing = 0.5f,
                Correction = 0.5f,
                Prediction = 0.5f,
                JitterRadius = 0.05f,
                MaxDeviationRadius = 0.04f
            });
            kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;
            swipeGestureRecognizer = new SwipeGestureDetector();
            swipeGestureRecognizer.OnGestureDetected += OnGestureDetected;
            skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, kinectCanvas);
            kinectSensor.Start();
            LoadGestureDetector();
            LoadLetterTPostureDetector();
            nuiCamera = new BindableNUICamera(kinectSensor);
            elevationSlider.DataContext = nuiCamera;
            voiceCommander = new VoiceCommander("record", "stop");
            voiceCommander.OrderDetected += voiceCommander_OrderDetected;
            StartVoiceCommander();
            kinectDisplay.DataContext = colorManager;

            dingPlayer = new SoundPlayer("ding.wav");  // Load sound
        }
Ejemplo n.º 3
0
    /// <summary>
    /// Initialize Kinect.
    /// </summary>
    void InitializeKinect() {
      if (kinectSensor == null)
        return;

      kinectSensor.ColorStream.Enable(HandInputParams.ColorImageFormat);

      kinectSensor.DepthStream.Enable(HandInputParams.DepthImageFormat);

      kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters {
        Smoothing = 0.5f,
        Correction = 0.5f,
        Prediction = 0.5f,
        JitterRadius = 0.05f,
        MaxDeviationRadius = 0.04f
      });
      skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor.CoordinateMapper,
                                                          skeletonCanvas);

      HandInputParams.ColorFocalLength = kinectSensor.ColorStream.NominalFocalLengthInPixels;
      HandInputParams.DepthFocalLength = kinectSensor.DepthStream.NominalFocalLengthInPixels;
      Log.InfoFormat("Color focal length = {0}", HandInputParams.ColorFocalLength);
      Log.InfoFormat("Depth focal length = {0}", HandInputParams.DepthFocalLength);
    }
        void StartKinect()
        {
            foreach (KinectSensor sensor in KinectSensor.KinectSensors)
            {
                if (sensor.Status == KinectStatus.Connected)
                {
                    Kinect = sensor;
                    break;
                }
            }

            if (Kinect == null)
            {
                ColorImage.Visibility = Visibility.Collapsed;
            }
            else
            {
                Kinect.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(Kinect_ColorFrameReady);
                Kinect.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
                outputBitmap = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
                ColorImage.Source = outputBitmap;

                //Skeleton detection
                Kinect.SkeletonStream.Enable(new TransformSmoothParameters
                                                   {
                                                 Smoothing = 0.5f,
                                                 Correction = 0.5f,
                                                 Prediction = 0.5f,
                                                 JitterRadius = 0.05f,
                                                 MaxDeviationRadius = 0.04f
                                             });
                Kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(Kinect_SkeletonFrameReady);
                skeletonDisplayManager = new SkeletonDisplayManager(Kinect, SkeletonCanvas);

                Kinect.Start();
            }
        }
Ejemplo n.º 5
0
        private void Initialize()
        {
            if (kinectRuntime == null)
                return;

            kinectRuntime.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
            kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
            kinectRuntime.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;
            kinectRuntime.VideoFrameReady += kinectRuntime_VideoFrameReady;

            swipeGestureRecognizer.OnGestureDetected += OnGestureDetected;

            skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, kinectCanvas);

            kinectRuntime.SkeletonEngine.TransformSmooth = true;
            var parameters = new TransformSmoothParameters
            {
                Smoothing = 1.0f,
                Correction = 0.1f,
                Prediction = 0.1f,
                JitterRadius = 0.05f,
                MaxDeviationRadius = 0.05f
            };
            kinectRuntime.SkeletonEngine.SmoothParameters = parameters;

            LoadCircleGestureDetector();
            LoadLetterTPostureDetector();

            nuiCamera = new BindableNUICamera(kinectRuntime.NuiCamera);

            elevationSlider.DataContext = nuiCamera;

            voiceCommander = new VoiceCommander("record", "stop");
            voiceCommander.OrderDetected += voiceCommander_OrderDetected;

            StartVoiceCommander();
        }
Ejemplo n.º 6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            circleKBPath = Path.Combine(Environment.CurrentDirectory, @"data\circleKB.save");
            letterT_KBPath = Path.Combine(Environment.CurrentDirectory, @"data\t_KB.save");
            try
            {
                kinectRuntime = new Runtime();
                kinectRuntime.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
                kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
                kinectRuntime.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;
                kinectRuntime.VideoFrameReady += kinectRuntime_VideoFrameReady;

                swipeGestureRecognizer.OnGestureDetected += OnGestureDetected;

                skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, kinectCanvas);

                kinectRuntime.SkeletonEngine.TransformSmooth = true;
                var parameters = new TransformSmoothParameters
                {
                    Smoothing = 1.0f,
                    Correction = 0.1f,
                    Prediction = 0.1f,
                    JitterRadius = 0.05f,
                    MaxDeviationRadius = 0.05f
                };
                kinectRuntime.SkeletonEngine.SmoothParameters = parameters;

                LoadCircleGestureDetector();
                LoadLetterTPostureDetector();

                nuiCamera = new BindableNUICamera(kinectRuntime.NuiCamera);

                elevationSlider.DataContext = nuiCamera;

                voiceCommander = new VoiceCommander("record", "stop");
                voiceCommander.OrderDetected += voiceCommander_OrderDetected;

                StartVoiceCommander();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 7
0
        private void Initialize()
        {
            if (_kinectSensor == null)
                return;

            audioManager = new AudioStreamManager(_kinectSensor.AudioSource);
            audioBeamAngle.DataContext = audioManager;

            _kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            _kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady;

            _kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
            _kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady;

            _kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters
                                                   {
                                                 Smoothing = 0.5f,
                                                 Correction = 0.5f,
                                                 Prediction = 0.5f,
                                                 JitterRadius = 0.05f,
                                                 MaxDeviationRadius = 0.04f
                                             });
            _kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;
            _gestureSuite = new GestureSuite();
            _gestureSuite.OnGestureDetected += OnGestureDetected;
            _gestureSuite.OnGestureDetected += UpdateGestureList;
            skeletonDisplayManager = new SkeletonDisplayManager(_kinectSensor, kinectCanvas);

            _kinectSensor.Start();

            LoadLetterTPostureDetector();

            nuiCamera = new BindableNUICamera(_kinectSensor);

            elevationSlider.DataContext = nuiCamera;

            voiceCommander = new VoiceCommander("record", "stop");
            voiceCommander.OrderDetected += voiceCommander_OrderDetected;

            StartVoiceCommander();

            kinectDisplay.DataContext = colorManager;
        }
        private void Initialize()
        {
            if (kinectSensor == null)
                return;

            audioManager = new AudioStreamManager(kinectSensor.AudioSource);
            audioBeamAngle.DataContext = audioManager;

            kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady;

            kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
            kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady;

            kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters
                                                   {
                                                 Smoothing = 0.5f,
                                                 Correction = 0.5f,
                                                 Prediction = 0.5f,
                                                 JitterRadius = 0.05f,
                                                 MaxDeviationRadius = 0.04f
                                             });
            kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;

            swipeGestureRecognizer = new SwipeGestureDetector();
            swipeGestureRecognizer.OnGestureDetected += OnGestureDetected;

            skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, kinectCanvas);

            kinectSensor.Start();

            LoadCircleGestureDetector();
            LoadLetterTPostureDetector();

            nuiCamera = new BindableNUICamera(kinectSensor);

            elevationSlider.DataContext = nuiCamera;

            voiceCommander = new VoiceCommander("record", "stop");
            voiceCommander.OrderDetected += voiceCommander_OrderDetected;

            StartVoiceCommander();

            kinectDisplay.DataContext = colorManager;

            parallelCombinedGestureDetector = new ParallelCombinedGestureDetector();
            parallelCombinedGestureDetector.OnGestureDetected += OnGestureDetected;
            parallelCombinedGestureDetector.Add(swipeGestureRecognizer);
            parallelCombinedGestureDetector.Add(circleGestureRecognizer);

            MouseController.Current.DisableGestureClick = false;

            //            kinectSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
        }
Ejemplo n.º 9
0
        public void Dispose()
        {
            if (skeletonDisplayManager != null)
            {
                skeletonDisplayManager = null;
            }
            if (colorManager != null)
            {
                colorManager = null;
            }
            if (depthManager != null)
            {
                depthManager = null;
            }

            if (speechRecognizer != null)
            {
                speechRecognizer.SpeechRecognized -= Speech_Recognized;
                speechRecognizer.Dispose();
                speechRecognizer = null;
            }
            
            if (gestureRecognizer != null)
            {
                gestureRecognizer.GestureRecognzied -= Gesture_Recognzied;
                gestureRecognizer.Dispose();
                gestureRecognizer = null;
            }

            if (kinectSensor != null)
            {
                kinectSensor.ColorFrameReady -= kinectRuntime_ColorFrameReady;
                kinectSensor.SkeletonFrameReady -= kinectRuntime_SkeletonFrameReady;
                kinectSensor.ColorFrameReady -= kinectRuntime_ColorFrameReady;
                kinectSensor.Stop();
                kinectSensor = null;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            this.MainWindowViewModel = new MainWindowViewModel();
            this.Loaded += this.MainWindowViewModel.OnWindowLoaded;
            this.Closed += this.MainWindowViewModel.OnWindowClosed;

            this.DataContext = this.MainWindowViewModel;

            // Skeleton stream.
            this.SkeletonDisplayManager = new SkeletonDisplayManager(this.MainWindowViewModel.Proxies.KinectSensor, this.ImageCanvas);
            this.Skeletons = null;

            this.MainWindowViewModel.Proxies.KinectSensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(this.KinectSensorSkeletonFrameReady);
        }
Ejemplo n.º 11
0
 public void LoadSkeletonDisplayManager(Canvas skeletonCanvas)
 {
     skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, skeletonCanvas);
 }
Ejemplo n.º 12
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            circleKBPath = Path.Combine(Environment.CurrentDirectory, @"data\circleKB.save");
            //rectangle
            rectangleKBPath = Path.Combine(Environment.CurrentDirectory, @"data\rectangleKB.save");

            //new gesture Step3: add new path
            pigtailKBPath = Path.Combine(Environment.CurrentDirectory, @"data\pigtailKB.save");
            checkKBPath = Path.Combine(Environment.CurrentDirectory, @"data\checkKB.save");
            starKBPath = Path.Combine(Environment.CurrentDirectory, @"data\starKB.save");

            letterT_KBPath = Path.Combine(Environment.CurrentDirectory, @"data\t_KB.save");

            //presentation: add presentation images to image array
            presentationImages[0] = presentationImage0;
            presentationImages[1] = presentationImage1;
            presentationImages[2] = presentationImage3;
            presentationImages[3] = presentationImage4;
            presentationImages[4] = presentationImage5;
            //presentationImages[5] = presentationImage5;

            try
            {
                kinectRuntime = new Runtime();
                kinectRuntime.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
                kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
                kinectRuntime.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;
                kinectRuntime.VideoFrameReady += kinectRuntime_VideoFrameReady;

                swipeGestureRecognizer.OnGestureDetected += OnGestureDetected;

                skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, kinectCanvas);

                kinectRuntime.SkeletonEngine.TransformSmooth = true;
                var parameters = new TransformSmoothParameters
                {
                    Smoothing = 1.0f,
                    Correction = 0.1f,
                    Prediction = 0.1f,
                    JitterRadius = 0.05f,
                    MaxDeviationRadius = 0.05f
                };
                kinectRuntime.SkeletonEngine.SmoothParameters = parameters;

                LoadCircleGestureDetector();
                LoadLetterTPostureDetector();
                //rectangle
                LoadRectangleGestureDetector();

                //new gesture Step4: load new detector();
                LoadPigtailGestureDetector();
                LoadCheckGestureDetector();
                LoadStarGestureDetector();

                nuiCamera = new BindableNUICamera(kinectRuntime.NuiCamera);

                elevationSlider.DataContext = nuiCamera;

                //voiceCommander = new VoiceCommander("record", "stop");

                //new gesture Step5: add new voice commander
                voiceCommander = new VoiceCommander("record", "stop", "circle", "rectangle", "flashstar",
                    "pigtail", "check", "end", "delete circle", "delete rectangle", "delete pigtail", "delete check", "delete flashstar");
                voiceCommander.OrderDetected += voiceCommander_OrderDetected;

                StartVoiceCommander();

                //presentationVideo.Stop();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Initialize()
        {
            InitialisationVille();
            if(kinectSensor == null)
                return;

            //kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution1280x960Fps12);
            kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);

            kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady;

            kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution80x60Fps30);
            kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady;

            kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters
            {
                Smoothing = 0.5f,
                Correction = 0.5f,
                Prediction = 0.5f,
                JitterRadius = 0.05f,
                MaxDeviationRadius = 0.04f
            });

            kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;

            swipeGestureReconnaissance = new NotreGestureDetecteur();
            swipeGestureReconnaissance.OnGestureDetected += OnGestureDetected;

            skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, kinectCanvas);
            kinectSensor.Start();

            nuiCamera = new BindableNUICamera(kinectSensor);
            zoneDeposable.Add(zoneLille);
            zoneDeposable.Add(zoneAix);
            zoneDeposable.Add(zoneBordeaux);
            zoneDeposable.Add(zoneLyon);
            zoneDeposable.Add(zoneNancy);
            zoneDeposable.Add(zoneNantes);
            zoneDeposable.Add(zoneOrléans);
            zoneDeposable.Add(zoneRennes);
            zoneDeposable.Add(zoneToulouse);
            zoneDeposable.Add(zoneParis);
            lesZonesDepots = new ZoneDeDepot(zoneDeposable);

            RecognizerInfo ri = GetKinectRecognizer();
            if (null != ri)
            {

               this.speechEngine = new SpeechRecognitionEngine(ri.Id);

               try
               {
                   // Create a grammar from grammar definition XML file.
                   using (var memoryStream = new MemoryStream(Encoding.ASCII.GetBytes(Properties.Resources.SpeechGrammar)))
                   {
                       Grammar g = new Grammar(memoryStream);
                       speechEngine.LoadGrammar(g);
                       Console.WriteLine("Reconnaissance vocale");
                   }
               }
               catch (ArgumentNullException a)
               {
                   Console.WriteLine("ERRREUR RECONNAISSANCE "+a);
               }
               catch (InvalidOperationException e)
               {
                    Console.WriteLine("ERRREUR RECONNAISSANCE "+e);
               }
               speechEngine.SpeechRecognized += SpeechRecognized;

                speechEngine.SetInputToAudioStream(
                    kinectSensor.AudioSource.Start(), new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
                speechEngine.RecognizeAsync(RecognizeMode.Multiple);
            }
               //Initialisation des boutons des villes
            String villeprincipale = villes.getNomVilleInitiale();
            btn1.Text = villeprincipale;
            textBoxInfoVille.FontSize = 18;
            LogTextBox.FontSize = 18;
            suivant.Text = villes.recupererNomVille(villeprincipale, "previous");
            precedent.Text = villes.recupererNomVille(villeprincipale, "next");
            textBoxInfoVille.Text = InformationVille.informationLille(); //lille debut
            Lille1Logo.Opacity = 1;//lille debut
            Lille1Logo.LoadedBehavior = MediaState.Play; //lilleDebut
            //a voir
            this.Cursor = Cursors.None;
        }
        /// <summary>
        /// Initialize the manager for use.
        /// </summary>
        public void Initialize()
        {
            if (kinect != null)
                return;

            kinect = Runtime.Kinects.Where(k => k.Status == KinectStatus.Connected).FirstOrDefault();

            if (kinect == null)
                return;

            this.kinect.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
            this.kinect.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);

            this.skeletonDisplayManager = new SkeletonDisplayManager(kinect.SkeletonEngine, skeletonCanvas);
            this.IsSkeletonVisible = true;

            this.displayStreamManager = new ColorStreamManager();

            kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady);
            kinect.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(kinect_VideoFrameReady);

            var handler = KinectConnected;
            if (handler != null)
                handler(kinect);
        }
Ejemplo n.º 15
0
        /*
         * Get everything initialized
         */
        public void Initialize()
        {
            if (kinectSensor == null)
                return;

            kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady;

            kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
            kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady;

            kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters
            {
                Smoothing = 0.5f,
                Correction = 0.5f,
                Prediction = 0.5f,
                JitterRadius = 0.05f,
                MaxDeviationRadius = 0.04f
            });
            kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;

            skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, kinectCanvas);
            //Add keywords that you wan to detect
            //v_commander = new VoiceCommander("record", "stop", "fly away", "flapping", "start", "finish", "write");

            kinectSensor.Start();
            //kinectDisplay.DataContext = colorManager;

            //v_commander.OrderDetected += voiceCommander_OrderDetected;
            //StartVoiceCommander();

            Dictionary<string, GesturePackage> gestureDic = fileManager.loadGesture();
            GesturePackage[] values = new GesturePackage[gestureDic.Values.Count];
            gestureDic.Values.CopyTo(values, 0);

            foreach (GesturePackage package in values)
            {
                gesture1_left.Add(package.getLeftCoordinates()[0]);
                gesture1_right.Add(package.getRightCoordinates()[0]);
            }
        }