示例#1
0
 /// <summary>
 /// This class handles detection of two handed gewtures. It inputs
 /// an algorithmic posture detector to detect changes in posture
 /// and appropriately react to these changes        
 /// </summary>
 /// <param name="postureDetector"></param>
 
 public TwoHandedGestureDetector(AlgorithmicPostureDetector postureDetector)
 {
     this._postureDetector = postureDetector;
     this._postureDetector.PostureDetected += DetectHandsOpening;
     _prevGesture = DateTime.MinValue;
     _prevHandClose = DateTime.MinValue;
 }
示例#2
0
        private void InitializeKinectManager()
        {
            if (kinectManager.KinectSensor != null && !kinectStartedSucessfully)
            {
                kinectManager.KinectSensor.ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(KinectSensor_ColorFrameReady);

                this.colorPixels   = new byte[kinectManager.KinectSensor.ColorStream.FramePixelDataLength];
                this.colorBitmap   = new WriteableBitmap(kinectManager.KinectSensor.ColorStream.FrameWidth, kinectManager.KinectSensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
                this.image1.Source = this.colorBitmap;

                kinectManager.PropertyChanged +=
                    new System.ComponentModel.PropertyChangedEventHandler(kinectManager_PropertyChanged);

                //kinectManager.KinectSensor.ElevationAngle = 15;

                textBoxMessagesCenter.Visibility = System.Windows.Visibility.Collapsed;
                kinectStartedSucessfully         = true;

                kinectManager.DetectMotion = true;
                kinectManager.MotionDetector.MotionDetected +=
                    new EventHandler(motionDetector_MotionDetected);

                kinectManager.FaceTracking = true;
                kinectManager.FaceTracker.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(FaceTracker_PropertyChanged);

                GestureDetector LeftHandSwipeGestureDetector =
                    new SwipeGestureDetector(Microsoft.Kinect.JointType.HandLeft);
                LeftHandSwipeGestureDetector.OnGestureDetected +=
                    new Action <string>(LeftHandSwipeGestureDetector_OnGestureDetected);
                kinectManager.GestureDetectors.Add(LeftHandSwipeGestureDetector);


                PostureDetector PostureDetector =
                    new AlgorithmicPostureDetector();
                PostureDetector.PostureDetected +=
                    new Action <string>(PostureDetector_PostureDetected);
                kinectManager.PostureDetectors.Add(PostureDetector);
            }

            if (!kinectStartedSucessfully)
            {
                textBoxMessagesCenter.Text       = "DISCONNECTED";
                textBoxMessagesCenter.Visibility = System.Windows.Visibility.Visible;
            }
        }
示例#3
0
        /// <summary>
        /// This class handles detection of two handed gewtures. It inputs
        /// an algorithmic posture detector to detect changes in posture
        /// and appropriately react to these changes        
        /// </summary>
        /// <param name="postureDetector"></param>
        
        public TwoHandedGestureDetector( AlgorithmicPostureDetector postureDetector)
        {
            //Initalize values to absolute minimum
            _prevGesture = DateTime.MinValue;
            _prevHandClose = DateTime.MinValue;
            _prevRHandOpen = DateTime.MinValue;
            _prevLHandOpen = DateTime.MinValue;
            _prevRHandClose = DateTime.MinValue;
            _prevLHandClose = DateTime.MinValue;

            _rightHandDetector = new DiagonalGestureDetector(RightHandOpen, RightHandClose);
            _leftHandDetector = new DiagonalGestureDetector(LeftHandOpen, LeftHandClose);
            _rightHandDetector.OnGestureDetected += GestureDetect;
            _leftHandDetector.OnGestureDetected += GestureDetect;
            
            _postureDetector = postureDetector;
            postureDetector.PostureDetected += GestureDetect;
        }
示例#4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            sensor = KinectSensor.KinectSensors.First();
            sensor.Start();
            sensor.ColorStream.Enable();
            sensor.DepthStream.Enable();
            sensor.SkeletonStream.Enable();
            Title = sensor.DeviceConnectionId;

            skeletonDisplayManager = new SkeletonDisplayManager(sensor, imageCanvas);

            gestureDetector = new SwipeGestureDetector();
            gestureDetector.DisplayCanvas = imageCanvas;
            gestureDetector.DisplayColor  = Colors.Red;

            postureDetector = new AlgorithmicPostureDetector();
            postureDetector.PostureDetected += postureDetector_PostureDetected;

            sensor.AllFramesReady             += sensor_AllFramesReady;
            gestureDetector.OnGestureDetected += gestureDetector_OnGestureDetected;
        }
        /// <summary>
        /// The default constructor.
        /// </summary>
        public SimpleKinectManager()
        {
            KinectManager = new KinectManager();

            KinectManager.PropertyChanged +=
                new System.ComponentModel.PropertyChangedEventHandler(kinectManager_PropertyChanged);

            KinectManager.DetectMotion = true;
            KinectManager.MotionDetector.MotionDetected +=
                new EventHandler(motionDetector_MotionDetected);

            KinectManager.FaceTracking = true;
            KinectManager.FaceTracker.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(FaceTracker_PropertyChanged);

            GestureDetector LeftHandSwipeGestureDetector =
                new SwipeGestureDetector(Microsoft.Kinect.JointType.HandLeft);

            LeftHandSwipeGestureDetector.OnGestureDetected +=
                new Action <string>(SwipeGestureDetector_OnGestureDetected);
            KinectManager.GestureDetectors.Add(LeftHandSwipeGestureDetector);

            GestureDetector RightHandSwipeGestureDetector =
                new SwipeGestureDetector(Microsoft.Kinect.JointType.HandRight);

            RightHandSwipeGestureDetector.OnGestureDetected +=
                new Action <string>(SwipeGestureDetector_OnGestureDetected);
            KinectManager.GestureDetectors.Add(RightHandSwipeGestureDetector);


            PostureDetector LeftHandOverHeadPostureDetector =
                new AlgorithmicPostureDetector();

            LeftHandOverHeadPostureDetector.PostureDetected +=
                new Action <string>(PostureDetector_OnPostureDetected);
            KinectManager.PostureDetectors.Add(LeftHandOverHeadPostureDetector);
        }