コード例 #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
 void Update()
 {
     if (Challenges == null)
     {
         if (MultiSourceBodyIDManager.Instance.GesturesList != null)
         {
             RoomEventManager.Challenges = new string[MultiSourceBodyIDManager.Instance.GesturesList.Count];
             for (int g = 0; g < MultiSourceBodyIDManager.Instance.GesturesList.Count; g++)
             {
                 Microsoft.Kinect.VisualGestureBuilder.Gesture gesture = MultiSourceBodyIDManager.Instance.GesturesList[g];
                 RoomEventManager.Challenges[g] = gesture.Name;
             }
         }
     }
 }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: noa99kee/K4W2-Book
 string gesture2string( Gesture gesture )
 {
     return gesture.Name.Trim();
 }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: noa99kee/K4W2-Book
        void result( VisualGestureBuilderFrame gestureFrame, Gesture gesture )
        {
            int count = GetIndexofGestureReader( gestureFrame );
            GestureType gestureType;
            gestureType = gesture.GestureType;
            switch ( gestureType ) {
            case GestureType.Discrete:
                DiscreteGestureResult dGestureResult;
                dGestureResult = gestureFrame.DiscreteGestureResults[gesture];

                bool detected;
                detected = dGestureResult.Detected;
                if ( !detected ) {
                    break;
                }

                float confidence = dGestureResult.Confidence;
                string discrete = gesture2string( gesture )
                        + " : Detected (" + confidence.ToString() + ")";
                GetTextBlock( count ).Text = discrete;//WPFのTextBlockに表示
                break;

            case GestureType.Continuous:
                ContinuousGestureResult cGestureResult;
                cGestureResult = gestureFrame.ContinuousGestureResults[gesture];

                float progress;
                progress = cGestureResult.Progress;
                string continuous = gesture2string( gesture )
                        + " : Progress " + progress.ToString();
                GetTextBlock( count ).Text = continuous;//WPFのTextBlockに表示
                break;
            default:
                break;
            }
        }
コード例 #5
0
        /// <summary>
        /// 初期設定
        /// </summary>
        private void Initialize()
        {
            // ColorImageの初期設定
            colorFrameDescription = kinect.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);
            colorImage = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96, 96, PixelFormats.Bgra32, null);
            ImageColor.Source = colorImage;

            // Bodyの初期設定
            bodies = new Body[kinect.BodyFrameSource.BodyCount];

            // Gesturesの初期設定
            gestureDatabase = new VisualGestureBuilderDatabase(@"../../Gestures/Jump.gbd");
            gestureFrameSource = new VisualGestureBuilderFrameSource(kinect, 0);

            // 使用するジェスチャーをデータベースから取り出す
            foreach (var gesture in gestureDatabase.AvailableGestures)
            {
                if (gesture.Name == "Jump")
                {
                    jump = gesture;
                }
                if (gesture.Name == "JumpProgress")
                {
                    jumpProgress = gesture;
                }
                this.gestureFrameSource.AddGesture(gesture);
            }

            // ジェスチャーリーダーを開く
            gestureFrameReader = gestureFrameSource.OpenReader();
            gestureFrameReader.IsPaused = true;
            gestureFrameReader.FrameArrived += gestureFrameReader_FrameArrived;

            // フレームリーダーを開く (Color / Body)
            multiFrameReader = kinect.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Body);
            multiFrameReader.MultiSourceFrameArrived += multiFrameReader_MultiSourceFrameArrived;
        }