コード例 #1
0
 private void sendContact(HandContact contact)
 {
     if (contact != null)
     {
         inputProvider.EnqueueContact(contact);
     }
 }
コード例 #2
0
 internal void EnqueueContact(HandContact contact)
 {
     lock (contactsQueue)
     {
         contactsQueue.Enqueue((HandContact)contact.Clone());
     }
 }
コード例 #3
0
        /// <summary>
        /// Update the status, means contact for driver as well as the cursor
        /// </summary>
        /// <param name="newStatus"></param>
        /// <returns></returns>
        private InputStatus updateStatus(InputStatus newStatus)
        {
            //generate contact for virtual touch driver
            if ((currentStatus == InputStatus.UNKNOWN || currentStatus == InputStatus.CURSOR) && newStatus == InputStatus.TOUCHED)
            {
                currentContact = new HandContact(position);
            }
            else if (currentStatus == InputStatus.TOUCHED)
            {
                currentContact.Update(position, newStatus);
            }
            else
            {
                newStatus = InputStatus.CURSOR;
                if (currentContact != null)
                {
                    currentContact.Update(position, newStatus);
                }
            }

            //set cursor
            if (currentStatus != newStatus)
            {
                currentStatus = newStatus;
                cursor.setBitmap(cursorImage[(int)newStatus]);
            }
            return(newStatus);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <param name="joint"></param>
        /// <param name="jointRef"></param>
        /// <param name="screenPlaneZoffset"></param>
        /// <returns>true if touched </returns>
        private void DetectVirtualRelativeTouch(User user, uint hand, SkeletonJoint jointRef, int screenPlaneZoffset)
        {
            SkeletonJoint jointHand;

            if (hand == 0)
            {
                jointHand = SkeletonJoint.LeftHand;
            }
            else
            {
                jointHand = SkeletonJoint.RightHand;
            }

            Point3D pos = user.Joints[jointHand].Position;

            Point3D posRef = user.Joints[jointRef].Position;

            InputStatus status;

            //hand not probably tracked return
            if (user.Joints[jointHand].Confidence < 0.6)
            {
                sendContact(user.updateHand(hand, InputStatus.UNKNOWN));
                return;
            } //if the reference is not valid, only cursor mode will be reliable
            else if (user.Joints[jointRef].Confidence < 0.6)
            {
                status = InputStatus.CURSOR;
            }
            else
            {     //both joints are well tracked, touch detection is executed
                if (pos.Z > (posRef.Z - screenPlaneZoffset))
                { //No Touch
                    status = InputStatus.CURSOR;
                }
                else
                {//Touch
                    status = InputStatus.TOUCHED;
                }
            }

            //convert kinectcoordinates to screencoordinates
            pos.X = virtualScreenXStart + virtualScreenConvertFactorX * (pos.X - kinectXCrop);
            pos.Y = virtualScreenYStart + virtualScreenConvertFactorY * (pos.Y - kinectYCrop);

            HandContact contact = user.updateHand(pos, hand, status);

            sendContact(contact);
        }
コード例 #5
0
        private void DetectVirtualAbsoluteTouch(User user, uint hand, int screenPlaneZoffset)
        {
            SkeletonJoint jointHand;

            if (hand == 0)
            {
                jointHand = SkeletonJoint.LeftHand;
            }
            else
            {
                jointHand = SkeletonJoint.RightHand;
            }

            Point3D pos = user.Joints[jointHand].Position;

            InputStatus status;

            //hand not probably tracked return
            if (user.Joints[jointHand].Confidence < 0.6)
            {
                sendContact(user.updateHand(hand, InputStatus.UNKNOWN));
                return;
            }
            else
            {     //both joints are well tracked, touch detection is executed
                if (pos.Z > screenPlaneZoffset)
                { //No Touch
                    status = InputStatus.CURSOR;
                }
                else
                {//Touch
                    status = InputStatus.TOUCHED;
                }
            }

            //convert kinectcoordinates to screencoordinates
            pos.X = virtualScreenXStart + virtualScreenConvertFactorX * (pos.X - kinectXCrop);
            pos.Y = virtualScreenYStart + virtualScreenConvertFactorY * (pos.Y - kinectYCrop);

            HandContact contact = user.updateHand(pos, hand, status);

            if (contact != null)
            {
                inputProvider.EnqueueContact(contact);
            }
        }
コード例 #6
0
        private void releaseUserTouches(int userId)
        {
            if (users.ContainsKey(userId))
            {
                User        user       = this.users[userId];
                HandContact contact    = user.updateHand(0, InputStatus.UNKNOWN);
                HandContact contactTwo = user.updateHand(1, InputStatus.UNKNOWN);

                if (contact != null)
                {
                    inputProvider.EnqueueContact(contact);
                }
                if (contactTwo != null)
                {
                    inputProvider.EnqueueContact(contactTwo);
                }
            }
        }
コード例 #7
0
 /// <summary>
 /// Copy contact
 /// </summary>
 /// <param name="clone"></param>
 public HandContact(HandContact clone)
     : base(clone.Id, clone.State, clone.Position, clone.MajorAxis, clone.MinorAxis)
 {
     Orientation = clone.Orientation;
 }
コード例 #8
0
 private void sendContact(HandContact contact)
 {
     if (contact != null)
     {
         inputProvider.EnqueueContact(contact);
     }
 }
コード例 #9
0
 /// <summary>
 /// Copy contact
 /// </summary>
 /// <param name="clone"></param>
 public HandContact(HandContact clone)
     : base(clone.Id, clone.State, clone.Position, clone.MajorAxis, clone.MinorAxis)
 {
     Orientation = clone.Orientation;
 }
コード例 #10
0
        /// <summary>
        /// Update the status, means contact for driver as well as the cursor
        /// </summary>
        /// <param name="newStatus"></param>
        /// <returns></returns>
        private InputStatus updateStatus(InputStatus newStatus)
        {
            //generate contact for virtual touch driver
            if ((currentStatus == InputStatus.UNKNOWN || currentStatus == InputStatus.CURSOR) && newStatus == InputStatus.TOUCHED)
            {
                currentContact = new HandContact(position);
            }
            else if (currentStatus == InputStatus.TOUCHED)
            {
                currentContact.Update(position, newStatus);
            }
            else
            {
                newStatus = InputStatus.CURSOR;
                if (currentContact != null)
                {
                    currentContact.Update(position, newStatus);
                }
            }

            //set cursor
            if (currentStatus != newStatus)
            {
                currentStatus = newStatus;
                cursor.setBitmap( cursorImage[(int)newStatus]);
            }
            return newStatus;
        }
コード例 #11
0
 internal void EnqueueContact(HandContact contact)
 {
     lock (contactsQueue)
     {
         contactsQueue.Enqueue((HandContact)contact.Clone());
     }
 }