Beispiel #1
0
        private double updateCurrentAngle(GESTURE gesture , GestureDatabase gestureDatabase)
        {
            double diffAngle = 0.0;

            Skeleton lastSkeleton;
            AppropriateJointInfo lastAptJointInfo;

            Skeleton lastValidSkeleton;
            AppropriateJointInfo lastValidAptJointInfo;

            int indexOfLastValidGesture = (gesture == GESTURE.SWIPE_RIGHT) ?
                                           indexOfLastValidSwipeRightFrame :
                                           indexOfLastValidSwipeLeftFrame;

            // compare the current frame with the last valid swipe right frame
            gestureDatabase.getLastRecord(out lastSkeleton, out lastAptJointInfo);
            gestureDatabase.getRecord(indexOfLastValidGesture, out lastValidSkeleton, out lastValidAptJointInfo);

            HCI580_Geometry.Vector2D lastElbowShoulder = new HCI580_Geometry.Vector2D(
                                                           (lastAptJointInfo.shoulderRightPos.X - lastAptJointInfo.elbowRightPos.X),
                                                           (lastAptJointInfo.shoulderRightPos.Y - lastAptJointInfo.elbowRightPos.Y));

            HCI580_Geometry.Vector2D lastElbowHand = new HCI580_Geometry.Vector2D(
                                                           (lastAptJointInfo.handRightPos.X - lastAptJointInfo.elbowRightPos.X),
                                                           (lastAptJointInfo.handRightPos.Y - lastAptJointInfo.elbowRightPos.Y));

            HCI580_Geometry.Vector2D lastValidElbowShoulder = new HCI580_Geometry.Vector2D(
                                                           (lastValidAptJointInfo.shoulderRightPos.X - lastValidAptJointInfo.elbowRightPos.X),
                                                           (lastValidAptJointInfo.shoulderRightPos.Y - lastValidAptJointInfo.elbowRightPos.Y));

            HCI580_Geometry.Vector2D lastValidElbowHand = new HCI580_Geometry.Vector2D(
                                                           (lastValidAptJointInfo.handRightPos.X - lastValidAptJointInfo.elbowRightPos.X),
                                                           (lastValidAptJointInfo.handRightPos.Y - lastValidAptJointInfo.elbowRightPos.Y));

            diffAngle = lastElbowShoulder.angleTo(lastElbowHand) - lastValidElbowShoulder.angleTo(lastValidElbowHand);

            // Console.WriteLine("diff Angle " +  diffAngle);
            diffAngle = (gesture == GESTURE.SWIPE_RIGHT) ? (diffAngle < 0 ? 0 : diffAngle) : (diffAngle > 0 ? 0 : diffAngle);

            // both the angles need to be added , as the diff angle will be negative for left swipes.
            return ((gesture == GESTURE.SWIPE_RIGHT) ? this.currentSwipeRightAngle + diffAngle : this.currentSwipeLeftAngle + diffAngle);
        }
Beispiel #2
0
        private bool isIntermediaryCumulativeAngularMotionValid(GESTURE gesture, GestureDatabase gestureDatabase)
        {
            Skeleton currentSkeleton;
            AppropriateJointInfo currentAptInfo;
            Skeleton firstValidSkeleton;
            AppropriateJointInfo firstValidAptInfo;
            int indexOfFirstValidMotion;

            indexOfFirstValidMotion =   (gesture == GESTURE.SWIPE_RIGHT) ?
                                        indexOfFirstValidSwipeRightFrame :
                                        indexOfFirstValidSwipeLeftFrame;

            gestureDatabase.getLastRecord(out currentSkeleton, out currentAptInfo);
            gestureDatabase.getRecord(indexOfFirstValidMotion,out firstValidSkeleton , out firstValidAptInfo);

            HCI580_Geometry.Vector2D currentElbowShoulder = new HCI580_Geometry.Vector2D((currentAptInfo.shoulderRightPos.X - currentAptInfo.elbowRightPos.X),
                                                                                         (currentAptInfo.shoulderRightPos.Y - currentAptInfo.elbowRightPos.Y));
            HCI580_Geometry.Vector2D currentElbowHand =     new HCI580_Geometry.Vector2D((currentAptInfo.handRightPos.X - currentAptInfo.elbowRightPos.X),
                                                                                         (currentAptInfo.handRightPos.Y - currentAptInfo.elbowRightPos.Y));

            HCI580_Geometry.Vector2D firstElbowShoulder = new HCI580_Geometry.Vector2D((firstValidAptInfo.shoulderRightPos.X - firstValidAptInfo.elbowRightPos.X),
                                                                                        (firstValidAptInfo.shoulderRightPos.Y - firstValidAptInfo.elbowRightPos.Y));
            HCI580_Geometry.Vector2D firstElbowHand = new HCI580_Geometry.Vector2D((firstValidAptInfo.handRightPos.X - firstValidAptInfo.elbowRightPos.X),
                                                                                         (firstValidAptInfo.handRightPos.Y - firstValidAptInfo.elbowRightPos.Y));

            double diffAngle =  currentElbowShoulder.angleTo(currentElbowHand) - firstElbowShoulder.angleTo(firstElbowHand);
            // Console.WriteLine("cumulative  diff " + diffAngle);
            return (gesture == GESTURE.SWIPE_RIGHT) ? (diffAngle > 0 ? true : false) : (diffAngle < 0 ? true : false);
        }
Beispiel #3
0
        // check for too fast and opposite movements
        private bool isHandAngularChangeWithInBounds(GESTURE gesture , GestureDatabase gestureDatabase)
        {
            Skeleton lastSkeleton;
            AppropriateJointInfo lastAptJointInfo;

            Skeleton lastValidSkeleton;
            AppropriateJointInfo lastValidAptJointInfo;

            int indexOfLastValidGesture = (gesture == GESTURE.SWIPE_RIGHT) ?
                                           indexOfLastValidSwipeRightFrame :
                                           indexOfLastValidSwipeLeftFrame;

            if (indexOfLastValidGesture < 0)
            {
                return true;
            }
            // compare the current frame with the last valid swipe right frame
            gestureDatabase.getLastRecord(out lastSkeleton , out lastAptJointInfo);
            gestureDatabase.getRecord(indexOfLastValidGesture , out lastValidSkeleton , out lastValidAptJointInfo);

            HCI580_Geometry.Vector2D lastElbowShoulder = new HCI580_Geometry.Vector2D(
                                                           (lastAptJointInfo.shoulderRightPos.X - lastAptJointInfo.elbowRightPos.X) ,
                                                           (lastAptJointInfo.shoulderRightPos.Y - lastAptJointInfo.elbowRightPos.Y));

            HCI580_Geometry.Vector2D lastElbowHand = new HCI580_Geometry.Vector2D(
                                                           (lastAptJointInfo.handRightPos.X - lastAptJointInfo.elbowRightPos.X),
                                                           (lastAptJointInfo.handRightPos.Y - lastAptJointInfo.elbowRightPos.Y));

            HCI580_Geometry.Vector2D lastValidElbowShoulder = new HCI580_Geometry.Vector2D(
                                                           (lastValidAptJointInfo.shoulderRightPos.X - lastValidAptJointInfo.elbowRightPos.X),
                                                           (lastValidAptJointInfo.shoulderRightPos.Y - lastValidAptJointInfo.elbowRightPos.Y));

            HCI580_Geometry.Vector2D lastValidElbowHand  = new HCI580_Geometry.Vector2D(
                                                           (lastValidAptJointInfo.handRightPos.X - lastValidAptJointInfo.elbowRightPos.X),
                                                           (lastValidAptJointInfo.handRightPos.Y - lastValidAptJointInfo.elbowRightPos.Y));

            if (Math.Abs(lastElbowShoulder.angleTo(lastElbowHand) - lastValidElbowShoulder.angleTo(lastValidElbowHand)) > MAX_RATE_OF_ANGLE_CHANGE)
            {
                // Console.WriteLine("angle change too fast");
                return false;       // moving too fast
            }

            // Console.WriteLine("last frame Angle " + lastElbowShoulder.angleTo(lastElbowHand) + " last Valid Frame Angle " + lastValidElbowShoulder.angleTo(lastValidElbowHand) +
            //                             " difference " + (lastElbowShoulder.angleTo(lastElbowHand) - lastValidElbowShoulder.angleTo(lastValidElbowHand)));
            switch (gesture)
            {
                case GESTURE.SWIPE_RIGHT:
                    {

                        /*
                         *  we are getting only the magnitude of the angles here, so swipe right opposite is moving from larger angle to smaller angle
                         */

                        if (lastElbowShoulder.angleTo(lastElbowHand) - lastValidElbowShoulder.angleTo(lastValidElbowHand) <= -THRESHOLD_OPPOSITE_ANGLE)
                        {
                            // Console.WriteLine("Gesture : SWIPE RIGHT , OPPOSITE MOTION ....");
                            return false;
                        }

                    }
                    break;
                case GESTURE.SWIPE_LEFT:
                    {
                        if (lastElbowShoulder.angleTo(lastElbowHand) - lastValidElbowShoulder.angleTo(lastValidElbowHand) >= THRESHOLD_OPPOSITE_ANGLE)
                        {
                            // Console.WriteLine("Gesture : SWIPE LEFT , OPPOSITE MOTION ....");
                            return false;
                        }

                    }
                    break;
            }

            return true;
        }
Beispiel #4
0
        /*
         * doc: The function takes the first valid gesture frame ,depending upon what the gesture is, and currently added
         *      and compares the shouldercenter position , which is representative of the body , accross these frames to
         *      check for out of range body movements
         */
        private bool isBodyLinearDeflectionWithInBounds(GESTURE gesture ,  GestureDatabase gestureDatabase)
        {
            Skeleton firstValidSkeleton;
            AppropriateJointInfo firstValidAptInfo;
            Skeleton currentSkeleton;
            AppropriateJointInfo currentAptInfo;

            int indexOfFirstValidGesture = (gesture == GESTURE.SWIPE_LEFT) ?
                                            indexOfFirstValidSwipeLeftFrame :
                                            indexOfFirstValidSwipeRightFrame;

            if(indexOfFirstValidGesture < 0)
                return true;

            gestureDatabase.getLastRecord(out currentSkeleton, out currentAptInfo);                           // last added frame
            gestureDatabase.getRecord(indexOfFirstValidGesture , out firstValidSkeleton , out firstValidAptInfo);       // first valid frame

            // difference between joint positions of shouldercenter in currently added and first valid gesture frame
            return isJointDelectionValid(currentAptInfo.shoulderCenterPos, firstValidAptInfo.shoulderCenterPos);
        }
        private bool isIntermediaryCumulativeAngleDeflectionValid(GESTURE gesture ,  GestureDatabase gestureDatabase)
        {
            Skeleton firstValidSkeleton;
            AppropriateJointInfo firstValidAptJointInfo;
            Skeleton currentSkeleton;
            AppropriateJointInfo currentAptJointInfo;

            int indexOfFirstValidGestureFrame = (gesture == GESTURE.CONST_LEFT) ?
                                                 indexOfFirstValidConstLeftGestureFrame :
                                                 indexOfFirstValidConstRightGestureFrame;

            gestureDatabase.getLastRecord(out currentSkeleton , out currentAptJointInfo);
            gestureDatabase.getRecord(indexOfFirstValidGestureFrame, out firstValidSkeleton , out firstValidAptJointInfo);

            Vector2D currentElbowShoulder = new Vector2D((currentAptJointInfo.shoulderRightPos.X - currentAptJointInfo.elbowRightPos.X),
                                                         (currentAptJointInfo.shoulderRightPos.Y - currentAptJointInfo.elbowRightPos.Y));
            Vector2D currentElbowHand = new Vector2D((currentAptJointInfo.handRightPos.X - currentAptJointInfo.elbowRightPos.X),
                                                         (currentAptJointInfo.handRightPos.Y - currentAptJointInfo.elbowRightPos.Y));

            Vector2D firstElbowShoulder = new Vector2D((firstValidAptJointInfo.shoulderRightPos.X - firstValidAptJointInfo.elbowRightPos.X),
                                                         (firstValidAptJointInfo.shoulderRightPos.Y - firstValidAptJointInfo.elbowRightPos.Y));
            Vector2D firstElbowHand = new Vector2D((firstValidAptJointInfo.handRightPos.X - firstValidAptJointInfo.elbowRightPos.X),
                                                         (firstValidAptJointInfo.handRightPos.Y - firstValidAptJointInfo.elbowRightPos.Y));

            double angularDeflection = Math.Abs(currentElbowShoulder.angleTo(currentElbowHand) - firstElbowShoulder.angleTo(firstElbowHand));

            if (angularDeflection <= THRESHOLD_ANGLE_DEFLECTION)
                return true;

            return false;
        }
        private bool isBodyLinearDeflectionsWithInBounds(GESTURE gesture , GestureDatabase gestureDatabase)
        {
            if(gesture == GESTURE.CONST_LEFT)
                if (indexOfFirstValidConstLeftGestureFrame < 0)
                    return true;                        // this is the start of the new Gesture, first frame of the new gesture

            if (gesture == GESTURE.CONST_RIGHT)
                if (indexOfFirstValidConstRightGestureFrame < 0)
                    return true;                        // this is the start of the new Gesture, first frame of the new gesture
            int indexOfFirstValidGestureFrame = (gesture == GESTURE.CONST_LEFT) ? indexOfFirstValidConstLeftGestureFrame :
                                                                                  indexOfFirstValidConstRightGestureFrame;

            Skeleton lastValidSkeleton;
            AppropriateJointInfo lastAptInfo;

            Skeleton firstValidSkeleton;
            AppropriateJointInfo firstAptInfo;

            gestureDatabase.getRecord(gestureDatabase.getTotalSize() - 1, out lastValidSkeleton, out lastAptInfo);
            gestureDatabase.getRecord(indexOfFirstValidGestureFrame, out firstValidSkeleton, out firstAptInfo);

            return (isPointWithInThreshold(lastAptInfo.shoulderCenterPos, firstAptInfo.shoulderCenterPos));
        }