Esempio n. 1
0
        private void KinectUserCreated(object sender, KinectUserEventArgs e)
        {
            WindowMessage = "User found";
            lock (SyncRoot)
            {
                if (_activeUser != null)
                {
                    return;
                }
                _activeUser          = _kinect.GetUser(e.User.Id);
                _activeUser.Updated += ActiveUserUpdated;

                var framesFilter = new FramesFilter(15);

                //Initialize filters
                _lefthandRighthandCollision     = new CollisionFilter(new Point3D(100, 50, 130), JointID.HandLeft, JointID.HandRight);
                _lefthandHeadCollision          = new CollisionFilter(new Point3D(150, 30, 500), JointID.HandLeft, JointID.Head);
                _lefthandRightShoulderCollision = new CollisionFilter(new Point3D(50, 50, 300), JointID.HandLeft, JointID.ShoulderRight);
                _righthandHeadCollision         = new CollisionFilter(new Point3D(125, 40, 150), JointID.HandRight, JointID.Head);
                _righthandLeftShoulderCollision = new CollisionFilter(new Point3D(50, 50, 300), JointID.HandRight, JointID.ShoulderLeft);
                _righthandRightHipCollision     = new CollisionFilter(new Point3D(80, 30, 200), JointID.HandRight, JointID.HipRight);

                //Initialize gestures
                _lefthandRighthandGesture     = new SelfTouchGesture(1);
                _lefthandHeadGesture          = new SelfTouchGesture(1);
                _lefthandRightShoulderGesture = new SelfTouchGesture(1);
                _righthandHeadGesture         = new SelfTouchGesture(1);
                _righthandLeftShoulderGesture = new SelfTouchGesture(1);
                _righthandRightHipGesture     = new SelfTouchGesture(1);

                //Attach filters and gestures
                _activeUser.AttachPipeline(framesFilter);
                framesFilter.AttachPipeline(_lefthandRighthandCollision);
                framesFilter.AttachPipeline(_lefthandHeadCollision);
                framesFilter.AttachPipeline(_lefthandRightShoulderCollision);
                framesFilter.AttachPipeline(_righthandHeadCollision);
                framesFilter.AttachPipeline(_righthandLeftShoulderCollision);
                framesFilter.AttachPipeline(_righthandRightHipCollision);
                _lefthandRighthandCollision.AttachPipeline(_lefthandRighthandGesture);
                _lefthandHeadCollision.AttachPipeline(_lefthandHeadGesture);
                _lefthandRightShoulderCollision.AttachPipeline(_lefthandRightShoulderGesture);
                _righthandHeadCollision.AttachPipeline(_righthandHeadGesture);
                _righthandLeftShoulderCollision.AttachPipeline(_righthandLeftShoulderGesture);
                _righthandRightHipCollision.AttachPipeline(_righthandRightHipGesture);

                _righthandLeftShoulderGesture.SelfTouchDetected += SwitchMode;

                //Debug info
                //_righthandLeftShoulderCollision.Filtered += (s, args) => ShowDebugInfo(args, "Filter info: ");
                _lefthandRightShoulderGesture.SelfTouchDetected += FireCustomEvent;
                SwitchMode(null, null);
            }
        }
        private void KinectUserCreated(object sender, KinectUserEventArgs e)
        {
            User user = _kinect.GetUser(e.User.Id);

            user.Updated += KinectUserUpdated;
            SelfTouchGesture gesture = user.AddSelfTouchGesture(new Point3D(0, 0, 0), JointID.HandLeft, JointID.HandRight);

            gesture.SelfTouchDetected += GestureSelfTouchDetected;
            _kinectUsers.Add(user);

            Action del2 = () => HandImage.Visibility = Visibility.Visible;

            HandImage.Dispatcher.BeginInvoke(DispatcherPriority.Send, del2);
        }
Esempio n. 3
0
        private void AddUserTouchEvents(User user)
        {
            //Need to lock. If the user is lost, you don't want that the user is getting set to null during adding of events
            lock (_syncRoot)
            {
                if (ConfigurationViewModel.EnableNextSlide)
                {
                    _nextSlideSelfTouch = user.AddSelfTouchGesture(ConfigurationViewModel.NextSlideCorrection,
                                                                   ConfigurationViewModel.NextSlide1,
                                                                   ConfigurationViewModel.NextSlide2);
                    _nextSlideSelfTouch.SelfTouchDetected +=
                        ((s, evt) =>
                    {
                        if (CheckEventInterval())
                        {
                            _log.DebugFormat("Next Slide \tUser:{0}", evt.UserID);
                            OnNextSlide(evt.UserID);
                        }
                    });
                    _log.DebugFormat("Added NextSlideEvent\tUser:{0}\tCorrection:{1}\t({2} on {3})", user.Id,
                                     ConfigurationViewModel.NextSlideCorrection.GetDebugString(),
                                     ConfigurationViewModel.NextSlide1, ConfigurationViewModel.NextSlide2);
                }

                if (ConfigurationViewModel.EnablePreviousSlide)
                {
                    _previousSlideSelfTouch = user.AddSelfTouchGesture(ConfigurationViewModel.PreviousSlideCorrection,
                                                                       ConfigurationViewModel.PreviousSlide1,
                                                                       ConfigurationViewModel.PreviousSlide2);
                    _previousSlideSelfTouch.SelfTouchDetected +=
                        ((s, evt) =>
                    {
                        if (CheckEventInterval())
                        {
                            _log.DebugFormat("Previous Slide \tUser:{0}", evt.UserID);
                            OnPreviousSlide(evt.UserID);
                        }
                    });
                    _log.DebugFormat("Added PreviousSlideEvent\tUser:{0}\tCorrection:{1}\t({2} on {3})", user.Id,
                                     ConfigurationViewModel.PreviousSlideCorrection.GetDebugString(),
                                     ConfigurationViewModel.PreviousSlide1, ConfigurationViewModel.PreviousSlide2);
                }

                if (ConfigurationViewModel.EnableTogglePointer)
                {
                    _togglePointerSelfTouch = user.AddSelfTouchGesture(ConfigurationViewModel.TogglePointerCorrection,
                                                                       ConfigurationViewModel.TogglePointer1,
                                                                       ConfigurationViewModel.TogglePointer2);
                    _togglePointerSelfTouch.SelfTouchDetected +=
                        ((s, evt) =>
                    {
                        if (CheckEventInterval())
                        {
                            _log.DebugFormat("TogglePointer \tUser:{0}", evt.UserID);
                            OnTogglePointer(evt.UserID);
                        }
                    });
                    _log.DebugFormat("Added TogglePointerEvent\tUser:{0}\tCorrection:{1}\t({2} on {3})", user.Id,
                                     ConfigurationViewModel.TogglePointerCorrection.GetDebugString(),
                                     ConfigurationViewModel.TogglePointer1, ConfigurationViewModel.TogglePointer2);
                }
            }
        }