Example #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);
        }
Example #2
0
        private bool isIntermediaryFrameValidGestureFrame(GESTURE gesture, GestureDatabase gestureDatabase)
        {
            Skeleton currentSkeleton;
            AppropriateJointInfo currentAptJointInfo;

            gestureDatabase.getLastRecord(out currentSkeleton, out currentAptJointInfo);

            switch (gesture)
            {
                case GESTURE.SWIPE_RIGHT:
                    {
                        HCI580_Geometry.Vector2D currentElbowShoulder = new HCI580_Geometry.Vector2D((currentAptJointInfo.shoulderRightPos.X - currentAptJointInfo.elbowRightPos.X),
                                                                                              (currentAptJointInfo.shoulderRightPos.Y - currentAptJointInfo.elbowRightPos.Y));

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

                        // check if hand Y > elbow Y , angle between elbowShoulder and elbowHand negative
                        if (currentAptJointInfo.handRightPos.Y > currentAptJointInfo.elbowRightPos.Y &&
                            currentElbowShoulder.cpsign(currentElbowHand) < 0)
                        {

                            return true;

                        }
                    }
                    break;
                case GESTURE.SWIPE_LEFT:
                    {
                        HCI580_Geometry.Vector2D currentElbowShoulder = new HCI580_Geometry.Vector2D((currentAptJointInfo.shoulderRightPos.X - currentAptJointInfo.elbowRightPos.X),
                                                                                              (currentAptJointInfo.shoulderRightPos.Y - currentAptJointInfo.elbowRightPos.Y));

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

                        // check if hand Y > elbow Y , angle between elbowShoulder and elbowHand negative
                        if (currentAptJointInfo.handRightPos.Y > currentAptJointInfo.elbowRightPos.Y &&
                            currentElbowShoulder.cpsign(currentElbowHand) < 0)
                        {
                            return true;
                        }
                    }
                    break;

            }
            return false;
        }
Example #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;
        }
Example #4
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);
        }
Example #5
0
        private bool isFirstValidGestureFrame(GESTURE gesture , GestureDatabase gestureDatabase)
        {
            Skeleton skeleton;
            AppropriateJointInfo aptJointInfo;

            gestureDatabase.getLastRecord(out skeleton ,out aptJointInfo);

            switch(gesture)
            {
                case GESTURE.SWIPE_RIGHT:
                    {
                        HCI580_Geometry.Vector2D elbowShoulder = new HCI580_Geometry.Vector2D((aptJointInfo.shoulderRightPos.X - aptJointInfo.elbowRightPos.X),
                                                                                              (aptJointInfo.shoulderRightPos.Y - aptJointInfo.elbowRightPos.Y));

                        HCI580_Geometry.Vector2D elbowHand = new HCI580_Geometry.Vector2D((aptJointInfo.handRightPos.X - aptJointInfo.elbowRightPos.X),
                                                                                          (aptJointInfo.handRightPos.Y - aptJointInfo.elbowRightPos.Y));

                        // check if hand Y > elbow Y , hand X < elbow X and angle between elbowShoulder and elbowHand negative
                        if(aptJointInfo.handRightPos.Y > aptJointInfo.elbowRightPos.Y &&
                           aptJointInfo.handRightPos.X < aptJointInfo.elbowRightPos.X &&
                           elbowShoulder.cpsign(elbowHand) < 0)
                        {
                            return true;
                        }
                    }
                    break;

                case GESTURE.SWIPE_LEFT:
                    {
                        HCI580_Geometry.Vector2D elbowShoulder = new HCI580_Geometry.Vector2D((aptJointInfo.shoulderRightPos.X - aptJointInfo.elbowRightPos.X),
                                                                                              (aptJointInfo.shoulderRightPos.Y - aptJointInfo.elbowRightPos.Y));

                        HCI580_Geometry.Vector2D elbowHand = new HCI580_Geometry.Vector2D((aptJointInfo.handRightPos.X - aptJointInfo.elbowRightPos.X),
                                                                                          (aptJointInfo.handRightPos.Y - aptJointInfo.elbowRightPos.Y));

                        // check if hand Y > elbow Y , hand X < elbow X and angle between elbowShoulder and elbowHand negative
                        if(aptJointInfo.handRightPos.Y > aptJointInfo.elbowRightPos.Y &&
                           aptJointInfo.handRightPos.X > aptJointInfo.elbowRightPos.X &&
                           elbowShoulder.cpsign(elbowHand) < 0)
                        {
                            return true;
                        }
                    }
                    break;

            }
            return false;
        }