예제 #1
0
        /// <summary>
        /// Maps the 3D hand session position to the current screen.
        /// </summary>
        /// <param name="session">The current hand session</param>
        /// <param name="targetWidth">The target mapping width</param>
        /// <param name="targetHeight">The target mapping height</param>
        /// <returns>2D Point representing the hand position mapped to the screen</returns>
        public virtual Point MapPositionToScreen(HandSession session, double targetWidth, double targetHeight)
        {
            Point3D position = session.PositionProjective;

            double x = MathUtility.MapValue(position.X, 10, 630, 0, targetWidth);
            double y = MathUtility.MapValue(position.Y, 30, 450, 0, targetHeight);

            return new Point(x, y);
        }
예제 #2
0
        private void UpdateHandSession(int id, OpenNI.Point3D position, OpenNI.Point3D shoulderPosition)
        {
            lock (HandSessions)
            {
                if (!HandSessions.ContainsKey(id))
                {
                    var session = new HandSession();
                    //session.PoseChanged += session_PoseChanged;
                    session.Id = id;
                    HandSessions.Add(session.Id, session);
                }

                HandSessions[id].xnPosition = position;
                HandSessions[id].Position = MotionHelper.XnPoint3DToPoint3D(position);
                HandSessions[id].ShoulderPosition = MotionHelper.XnPoint3DToPoint3D(shoulderPosition);
                OpenNI.Point3D projective = depthGenerator.ConvertRealWorldToProjective(position);
                HandSessions[id].PositionProjective = MotionHelper.XnPoint3DToPoint3D(projective);
                OnPointUpdated(id, HandSessions[id]);

            }
        }
예제 #3
0
 private void OnPointUpdated(int id, HandSession session)
 {
     if (PointUpdated == null)
         return;
     PointUpdated(null, new HandPointEventArgs(id, HandPointStatus.Move, session));
 }
예제 #4
0
 private void OnPointDestroyed(int id, HandSession session)
 {
     if (PointDestroyed == null)
         return;
     PointDestroyed(null, new HandPointEventArgs(id, HandPointStatus.Up, session));
 }
        internal void TouchUp(HandPointEventArgs e)
        {
            if (lastEventType != EventType.TouchMoveIntermediate)
            {
                intermediateEvents.Clear();
            }

            if (!this.IsActive)
            {
                return;
            }

            this.lastEventArgs = e;
            this.Session = null;
            this.ReportUp();
            this.Deactivate();
            lastEventType = EventType.TouchUp;
        }
 internal void TouchMove(HandPointEventArgs e)
 {
     if (!this.IsActive)
     {
         return;
     }
     this.Session = e.Session;
     CoalesceEvents(e);
 }
        internal void TouchDown(HandPointEventArgs e)
        {
            if (lastEventType != EventType.TouchMoveIntermediate)
            {
                intermediateEvents.Clear();
            }

            this.lastEventArgs = e;
            lastEventPosition = screen.MapPositionToScreen(e.Session);
            lastEventTime = DateTime.Now;
            lastEventType = EventType.TouchDown;
            this.Session = e.Session;
            var source = PresentationSource.FromVisual(this.rootWindow);
            this.SetActiveSource(source);
            this.Activate();
            this.ReportDown();
        }
예제 #8
0
 public Point MapPositionToScreen(HandSession session)
 {
     return MapPositionToScreen(session, this.ScreenWidth, this.ScreenHeight);
 }
예제 #9
0
 public virtual bool IsSessionInBounds(HandSession session)
 {
     return true;
 }
예제 #10
0
 public HandPointEventArgs(int id, HandPointStatus status, HandSession session)
 {
     this.Id = id;
     this.Status = status;
     this.Session = session;
 }