Exemplo n.º 1
0
        //Constractor
        public GestureDetector(KinectSensor _sensor, GestureAnalysis _gestureAnalysis, Exercise _currentExercise)
        {
            if (_sensor == null)
            {
                throw new ArgumentNullException("kinectSensor");
            }

            if (_gestureAnalysis == null)
            {
                throw new ArgumentNullException("gestureResultView");
            }

            this._sensor          = _sensor;
            this._gestureAnalysis = _gestureAnalysis;


            // create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor.
            vgbFrameSource = new VisualGestureBuilderFrameSource(_sensor, 0);
            //vgbFrameSource.TrackingIdLost += Source_TrackingIdLost;

            // open the reader for the vgb frames
            vgbFrameReader = vgbFrameSource.OpenReader();
            if (this.vgbFrameReader != null)
            {
                vgbFrameReader.IsPaused      = true;
                vgbFrameReader.FrameArrived += VgbFrameReader_FrameArrived;
            }

            // load all gestures from the gesture database
            if (File.Exists(_currentExercise.DBPath))
            {
                using (var database = new VisualGestureBuilderDatabase(_currentExercise.DBPath))
                {
                    vgbFrameSource.AddGestures(database.AvailableGestures);

                    //setup the continuous gesture
                    foreach (var gesture in database.AvailableGestures)
                    {
                        if (gesture.Name.Equals(_currentExercise.ContinuousGestureName))
                        {
                            ContinuousGestureData = gesture;
                            break;
                        }
                    }
                }

                //todo - implmnt gesture disable
                foreach (var gesutre in this.vgbFrameSource.Gestures)
                {
                    foreach (var notTrackGesture in _currentExercise.VTGestureList)
                    {
                        if (gesutre.Name.Equals(notTrackGesture.GestureName) && !notTrackGesture.IsTrack)
                        {
                            vgbFrameSource.SetIsEnabled(gesutre, false);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Constractor
        public GestureDetector(KinectSensor _sensor, GestureAnalysis _gestureAnalysis, Exercise _currentExercise)
        {
            if (_sensor == null)
            {
                throw new ArgumentNullException("kinectSensor");
            }

            if (_gestureAnalysis == null)
            {
                throw new ArgumentNullException("gestureResultView");
            }

            this._sensor = _sensor;
            this._gestureAnalysis = _gestureAnalysis;

            // create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor.
            vgbFrameSource = new VisualGestureBuilderFrameSource(_sensor, 0);
            //vgbFrameSource.TrackingIdLost += Source_TrackingIdLost;

            // open the reader for the vgb frames
            vgbFrameReader = vgbFrameSource.OpenReader();
            if (this.vgbFrameReader != null)
            {
                vgbFrameReader.IsPaused = true;
                vgbFrameReader.FrameArrived += VgbFrameReader_FrameArrived;
            }

            // load all gestures from the gesture database
            if (File.Exists(_currentExercise.DBPath))
            {
                using (var database = new VisualGestureBuilderDatabase(_currentExercise.DBPath))
                {
                    vgbFrameSource.AddGestures(database.AvailableGestures);

                    //setup the continuous gesture
                    foreach (var gesture in database.AvailableGestures)
                    {
                        if (gesture.Name.Equals(_currentExercise.ContinuousGestureName))
                        {
                            ContinuousGestureData = gesture;
                            break;
                        }
                    }
                }

                //todo - implmnt gesture disable
                foreach (var gesutre in this.vgbFrameSource.Gestures)
                {
                    foreach (var notTrackGesture in _currentExercise.VTGestureList)
                    {
                        if (gesutre.Name.Equals(notTrackGesture.GestureName) && !notTrackGesture.IsTrack)
                        {
                            vgbFrameSource.SetIsEnabled(gesutre, false);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Dispose()
        {
            if (_gestureDetector != null)
            {
                _gestureDetector.Dispose();
            }

            if (_reader != null)
            {
                _reader.Dispose();
            }

            if (_gestureAnalysis != null)
            {
                _gestureAnalysis = null;
            }

            if (_sensor != null)
            {
                _sensor.Close();
                _sensor = null;
            }


        }
Exemplo n.º 4
0
        private void StartTraceableMode()
        {
            SetUIInTrackingMode();

            //ExerciseVideo.Play();

            _sensor = KinectSensor.GetDefault();
            
            //todo - check, not working
            if (_sensor != null)
            {
                _sensor.Open();

                // 2) Initialize the background removal tool.
                _backgroundRemovalTool = new BackgroundRemovalTool(_sensor.CoordinateMapper);
                _drawSkeleton = new DrawSkeleton(_sensor, (int)(KinectSkeleton.Width), (int)(KinectSkeleton.Height));

                _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.BodyIndex | FrameSourceTypes.Body);
                _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;
                
                //Gesture detection
                Exercise tempExercise = CurrentExercise;

                _gestureAnalysis = new GestureAnalysis(ref tempExercise);
                _gestureDetector = new GestureDetector(_sensor, _gestureAnalysis, CurrentExercise);

                _gestureAnalysis.startGestureDeteced += _gestureAnalysis_startGestureDeteced;

                CurrentExercise.CreateRounds();

                //_timer.Start();
            }

            ExerciseVideo.Play();
            inPlayMode = true;
        }