Exemplo n.º 1
0
        //Check IF pass all rules of 1 Posture
        public static Boolean testDetect1Posture(UKI_Data_AnalysisForm row, List <m_If> current_posture, ref int time_wait)
        {
            Boolean pass_1Posture = false;

            foreach (m_If subRule in current_posture)
            {
                if (subRule.type == TheMapData.if_type_TimeAfterPose)
                {
                    time_wait = (int)subRule.value_d * fps;
                }
                else
                {
                    pass_1Posture = testRule(row, subRule);
                    if (!pass_1Posture)
                    {
                        break;
                    }
                }
            }
            return(pass_1Posture);
        }
Exemplo n.º 2
0
        // 1 data - 1 rule
        public static Boolean testRule(UKI_Data_AnalysisForm data, m_If rule)
        {
            Boolean pass = false;

            if (rule.type == TheMapData.if_type_2Joint)
            {
                double diff = 0;
                if (rule.axis == "X" || rule.axis == "Y" || rule.axis == "Z")
                {
                    double v1 = getJointAxis(data.raw, rule.v, rule.axis);
                    double v2 = getJointAxis(data.raw, rule.v2, rule.axis);
                    diff = v1 - v2;
                }
                else
                {
                    diff = TheTool.calEuclidian(getJoint(data.raw, rule.v), getJoint(data.raw, rule.v2));
                }
                pass = TheTool.checkOpt(diff, rule.opt, rule.value_d);
            }
            else if (rule.type == TheMapData.if_type_BasicPose)
            {
                pass = UKI_DataBasicPose_checkBasicPosture(rule, data.bp);
            }
            else if (rule.type == TheMapData.if_type_Change)
            {
                double v1         = getJointAxis(data.raw, rule.v, rule.axis);
                double v2         = getJointAxis(TheInitialPosture.data_raw, rule.v2, rule.axis);
                double test_value = v1 - v2;
                pass = TheTool.checkOpt(test_value, rule.opt, rule.value_d);
                //TheSys.showError(v1 + " - " + v2 + " = " + test_value + rule.opt + rule.value_d);
            }
            else if (rule.type == TheMapData.if_type_SphereAngle)
            {
                Boolean azimuth = false;
                if (rule.value == TheMapData.then_SphereAngle_Azimuth)
                {
                    azimuth = true;
                }
                double testValue = TheTool.calSpherical(getJoint(data.raw, rule.v), getJoint(data.raw, rule.v2), azimuth);
                pass = TheTool.checkOpt(testValue, rule.opt, rule.value_d);
            }
            else if (rule.type == TheMapData.if_type_FlexionAngle)
            {
                double testValue = 0;
                if (rule.v == "ElbowL")
                {
                    testValue = ThePostureCal.calAngle_3Points(data.raw.ShoulderLeft, data.raw.ElbowLeft, data.raw.WristLeft);
                }
                else if (rule.v == "ElbowR")
                {
                    testValue = ThePostureCal.calAngle_3Points(data.raw.ShoulderRight, data.raw.ElbowRight, data.raw.WristRight);
                }
                else if (rule.v == "KneeL")
                {
                    testValue = ThePostureCal.calAngle_3Points(data.raw.HipLeft, data.raw.KneeLeft, data.raw.AnkleLeft);
                }
                else if (rule.v == "KneeR")
                {
                    testValue = ThePostureCal.calAngle_3Points(data.raw.HipRight, data.raw.KneeRight, data.raw.AnkleRight);
                }
                pass = TheTool.checkOpt(testValue, rule.opt, rule.value_d);
            }
            return(pass);
        }