Esempio n. 1
0
        //Modeling transition patterns between events for temporal human action segmentation and classification
        public static List <int[]> extractKeyPose_Angular(Instance inst)
        {
            List <int[]>          list_keyPose    = new List <int[]>();
            List <UKI_DataDouble> list_dataAngles = new List <UKI_DataDouble>();
            List <string>         output_print    = new List <string>();

            foreach (UKI_DataRaw d in inst.getDataRaw(false))
            {
                UKI_DataDouble dataAngles = new UKI_DataDouble();
                dataAngles.id = d.id;
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.Spine, d.ShoulderLeft, d.ElbowLeft));
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.ShoulderLeft, d.ElbowLeft, d.WristLeft));
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.Spine, d.ShoulderRight, d.ElbowRight));
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.ShoulderRight, d.ElbowRight, d.WristRight));
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.Spine, d.HipLeft, d.KneeLeft));
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.HipLeft, d.KneeLeft, d.AnkleLeft));
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.Spine, d.HipRight, d.KneeRight));
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.HipLeft, d.KneeLeft, d.AnkleLeft));
                dataAngles.data.Add(ThePostureCal.calAngle_3Points(d.Head, d.ShoulderCenter, d.Spine));
            }
            if (path_saveFolder != "")
            {
                output_print.Add("id,ShouldL,ElbowL,ShouldR,ElbowR,HipL,KneeL,HipR,KneeR,Neck");
                output_print.AddRange(TheUKI.UKI_DataDouble_convertToListString(list_dataAngles));
                TheTool.exportCSV_orTXT(path_saveFolder + @"/" + inst.name + ".csv", output_print, false);
            }
            return(list_keyPose);
        }
Esempio 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);
        }