예제 #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);
                        }
                    }
                }
            }
        }
예제 #2
0
        public GestureTracker(KinectSensor sensor, string gesturesDB)
        {
            _gestureSource = new VisualGestureBuilderFrameSource(sensor, 0);
            _gestureReader = _gestureSource.OpenReader();

            IsPaused = true;

            using (VisualGestureBuilderDatabase db = new VisualGestureBuilderDatabase(gesturesDB))
            {
                _gestureSource.AddGestures(db.AvailableGestures);
            }
        }
예제 #3
0
 public GestureDetector(KinectSensor kinectSensor,GestureResultView gestureResultView)
 {
     if(kinectSensor == null)
     {
         throw new ArgumentException("Kinect sensor is null");
     }
     if(gestureResultView == null)
     {
         throw new ArgumentException("GestureResultView is null");
     }
     GestureResultView = gestureResultView;
     gestureFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0);
     gestureFrameSource.TrackingIdLost += Source_TackingiIdLost;
     gestureFrameReader = gestureFrameSource.OpenReader();
     if(gestureFrameReader != null)
     {
         gestureFrameReader.IsPaused = true;
         gestureFrameReader.FrameArrived += GestureFrameArrived;
     }
     using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(GESTURE_DATABASE))
     {
         //load all available gesture from database
         //May need optimization when the gesture list gets really large
         gestureFrameSource.AddGestures(database.AvailableGestures);
     }
     
     gestureNameList = new ReadOnlyCollection<string>
         (
             new string[]
             {
                 WALKING_FORWARD_NAME,
                 JUMPING_GESTURE_NAME,
                 LEFT_CLICK_NAME,
                 RIGHT_CLICK_NAME,
                 OPEN_INVENTORY_NAME,
                 MOVE_MOUSE_LEFT,
                 MOVE_MOUSE_RIGHT,
                 MOVE_MOUSE_UP,
                 MOVE_MOUSE_DOWN,
                 STOP_GESTURE
             }
         );
 }
예제 #4
0
        void InitializeGesture()
        {
            gestureFrameReaders = new VisualGestureBuilderFrameReader[BODY_COUNT];
            for ( int count =0; count < BODY_COUNT; count++ ) {
                VisualGestureBuilderFrameSource gestureFrameSource;
                gestureFrameSource = new VisualGestureBuilderFrameSource( kinect, 0 );
                gestureFrameReaders[count] = gestureFrameSource.OpenReader();
                gestureFrameReaders[count].FrameArrived += gestureFrameReaders_FrameArrived;
            }

            VisualGestureBuilderDatabase gestureDatabase;
            gestureDatabase = new VisualGestureBuilderDatabase( "SampleDatabase.gbd" );

            uint gestureCount;
            gestureCount = gestureDatabase.AvailableGesturesCount;
            gestures = gestureDatabase.AvailableGestures;
            for ( int count = 0; count<BODY_COUNT; count++ ) {
                VisualGestureBuilderFrameSource gestureFrameSource;
                gestureFrameSource = gestureFrameReaders[count].VisualGestureBuilderFrameSource;
                gestureFrameSource.AddGestures( gestures );
                foreach ( var g in gestures ) {
                    gestureFrameSource.SetIsEnabled( g, true );
                }
            }
        }
            /// <summary>
            /// Initializes a new instance of the GestureDetector class along with the gesture frame source and reader
            /// </summary>
            /// <param name="kinectSensor">Active sensor to initialize the VisualGestureBuilderFrameSource object with</param>
            /// <param name="gestureResultView">GestureResultView object to store gesture results of a single body to</param>
            public GestureDetector(KinectSensor kinectSensor, GestureResultView gestureResultView)
            {
                if (kinectSensor == null)
                {
                    throw new ArgumentNullException("kinectSensor");
                }

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

                this.GestureResultView = gestureResultView;

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

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

                // load the gestures from the gesture database
                using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(this.gestureDatabase))
                {
                    vgbFrameSource.AddGestures(database.AvailableGestures);
                }
            }