コード例 #1
0
        private static void changeControlState(bool turnOn, WrongPostures wp)
        {
            SolidColorBrush brush;

            brush = turnOn ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.LightGray);

            switch (wp)
            {
            case WrongPostures.Crouching:
                mainWindowRef.crouchingControl.Fill = brush;
                break;

            case WrongPostures.LeaningForward: mainWindowRef.leaningForwardControl.Fill = brush;
                break;

            case WrongPostures.Lounge: mainWindowRef.loungingControl.Fill = brush;
                break;

            case WrongPostures.NeckFront: mainWindowRef.neckFrontControl.Fill = brush;
                break;

            case WrongPostures.Sideways: mainWindowRef.sidewaysBendControl.Fill = brush;
                break;

            case WrongPostures.PostureOK:
                mainWindowRef.crouchingControl.Fill      = brush;
                mainWindowRef.leaningForwardControl.Fill = brush;
                mainWindowRef.loungingControl.Fill       = brush;
                mainWindowRef.neckFrontControl.Fill      = brush;
                mainWindowRef.sidewaysBendControl.Fill   = brush;
                break;
            }
        }
コード例 #2
0
        public static String postureToString(WrongPostures wp)
        {
            switch (wp)
            {
            case WrongPostures.Crouching:

                return("CROUCHING: Garbisz się!");

            case WrongPostures.KneesBended: return("KNEESBENDED: Wyprostuj kolana!");

            case WrongPostures.LeaningForward: return("LEANINGFWD: Pochylasz się do przodu!");

            case WrongPostures.Lounge: return("LOUNGE: Lezysz!");

            case WrongPostures.NeckFront: return("NECKFRONT: Szyja jest za bardzo do przodu!");

            case WrongPostures.Sideways: return("SIDEWAYS: Za bardzo na bok...");

            case WrongPostures.PostureOK: return("POSTURE OK :)");

            default: return("default");
            }
        }
コード例 #3
0
        //todo: define all gestures
        public static WrongPostures diagnozeWrongPosture(CurrentPostureParams cpp)
        {
            double averageShouldersZ                 = (cpp.shoulderLeftZcurrent + cpp.shoulderRightZcurrent) / 2;
            double shouldersZratio                   = cpp.shoulderCenterZcurrent / cpp.shouldersCenterZideal;
            double chinZratio                        = cpp.chinZcurrent / cpp.chinZideal;
            double headShouldersYdistanceRatio       = (cpp.headYcurrent - cpp.shouldersCenterYcurrent) / cpp.headShouldersCenterYideal;
            double avereageShoulderZ_sideways_center = averageShouldersZ - cpp.shoulderCenterZcurrent;
            double averageShoulderLRRatio            = averageShouldersZ / cpp.averageShouldersZideal;

            WrongPostures detectedPosture = WrongPostures.PostureOK;

            mainWindowRef.ratioChinZcontrol.Text     = chinZratio.ToString("0.##");
            mainWindowRef.shoulderLeftZcontrol.Text  = cpp.shoulderLeftZcurrent.ToString("0.##");
            mainWindowRef.shoulderRightZcontrol.Text = cpp.shoulderRightZcurrent.ToString("0.##");
            mainWindowRef.roznicaShoulderCenterShoulderLFcontrol.Text = avereageShoulderZ_sideways_center.ToString("0.##");
            mainWindowRef.ratioHeadShouldersYControl.Text             = headShouldersYdistanceRatio.ToString("0.##");
            mainWindowRef.neckAngleControl.Text              = cpp.neckAngleCurrent.ToString("0.##");
            mainWindowRef.ratioShoulderZcontrol.Text         = shouldersZratio.ToString("0.##");
            mainWindowRef.averageShoulderLRRatioControl.Text = averageShouldersZ.ToString("0.##");

            if (checkNeckFrontOK(cpp.neckAngleCurrent, cpp.headTilt, chinZratio) == false)
            {
                changeControlState(true, WrongPostures.NeckFront);
                detectedPosture = WrongPostures.NeckFront;
            }
            else
            {
                changeControlState(false, WrongPostures.NeckFront);
            }



            if (checkLeaningForwardOK(cpp.headTilt, chinZratio, shouldersZratio) == false)
            {
                changeControlState(true, WrongPostures.LeaningForward);

                detectedPosture = WrongPostures.LeaningForward;
            }
            else
            {
                changeControlState(false, WrongPostures.LeaningForward);
            }


            if (checkLoungeOK(cpp.headTilt, chinZratio, shouldersZratio, cpp.neckAngleCurrent, headShouldersYdistanceRatio) == false)
            {
                changeControlState(true, WrongPostures.Lounge);

                detectedPosture = WrongPostures.Lounge;
            }
            else
            {
                changeControlState(false, WrongPostures.Lounge);
            }


            if (checkSidewaysOK(cpp.shoulderLeftZcurrent, cpp.shoulderRightZcurrent, cpp.headRoll,
                                cpp.headYaw, cpp.leftWristYposition, cpp.rightWristYpostion, cpp.shouldersCenterYcurrent) == false)
            {
                changeControlState(true, WrongPostures.Sideways);

                detectedPosture = WrongPostures.Sideways;
            }

            else
            {
                changeControlState(false, WrongPostures.Sideways);
            }


            if (checkCrouchingOK(cpp.headTilt, avereageShoulderZ_sideways_center, headShouldersYdistanceRatio, averageShoulderLRRatio) == false)
            {
                changeControlState(true, WrongPostures.Crouching);

                detectedPosture = WrongPostures.Crouching;
            }
            else
            {
                changeControlState(false, WrongPostures.Crouching);
            }

            if (detectedPosture == WrongPostures.PostureOK)
            {
                changeControlState(false, WrongPostures.PostureOK);
            }
            return(detectedPosture);
        }