Пример #1
0
        public void OpenReader()
        {
            reader = sensor.BodyFrameSource.OpenReader();
            reader.FrameArrived += OnFrameArrived;
            gestureDetectorList = new List<GestureDetector>();
            int maxBodies = sensor.BodyFrameSource.BodyCount;
            for (int i = 0; i <= maxBodies; i++)
            {
                //body count index stored inside the gestureResultView object starting at 0
                GestureResultView result = new GestureResultView(i, false, false, 0.0f);
                GestureDetector detector = new GestureDetector(sensor, result);

                result.PropertyChanged += GestureResult_PropertyChanged;
                gestureDetectorList.Add(detector);
            }

        }
Пример #2
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
             }
         );
 }