Ejemplo n.º 1
0
        void motionModel_evaluationEach(string header, m_Motion motion)
        {
            summary_total.Add("");
            List <string> motionFailed = new List <string>();

            int           detectected_count = 0;
            int           all_inst          = container.list_inst.Count();
            List <string> all_log           = new List <string>();

            foreach (Instance inst in container.list_inst)
            {
                Boolean      detected = TheRuleTester.testDetectMotion(inst.getDataRaw(true), motion.inputs);
                logDetection log      = TheRuleTester.temp_log;
                string       s        = "";
                if (detected)
                {
                    s += "[O] ";
                    detectected_count++;
                }
                else
                {
                    s += "[X] ";
                    motionFailed.Add(inst.name + " is unrecognized with " + header);
                }
                s += inst.name + " [" + log.info + "]";
                all_log.Add(s);
            }
            double acc = (double)detectected_count * 100 / all_inst;

            acc = Math.Round(acc, 2);
            //---------
            summary_total.Add(header += " : " + acc + "% (" + detectected_count + "/" + all_inst + ")");
            foreach (string s in all_log)
            {
                summary_total.Add(s);
            }
            if (acc < 100)
            {
                TheTool.exportFile(motionFailed, TheTool.filePath + "all_incomplete_motion.txt", false, true);
            }
        }
Ejemplo n.º 2
0
        //Motion Analysis on 1 File
        //All Data (Whole Sequence) - All Motion
        //Output: Matrix
        static public string motionAnalysis(String path_load, String path_save, List <m_Motion> list_motions)
        {
            string              currentFileName = TheTool.getFileName_byPath(path_load);
            string              matrix_data     = currentFileName;
            List <UKI_DataRaw>  list_raw        = TheUKI.csv_loadFileTo_DataRaw(path_load, 0);
            List <logDetection> log_list        = new List <logDetection>();//keep output summary
            //--- Preprocess to obtain BasePosture Data
            UKI_Offline mr = new UKI_Offline();

            mr.UKI_OfflineProcessing(list_raw, 0);
            List <UKI_Data_AnalysisForm> data = TheUKI.getData_AnalysisForm(mr.data.data_raw, mr.data.data_bp);

            //--- Analysis Motion by Motion
            foreach (m_Motion motion in list_motions)
            {
                Boolean      detected = TheRuleTester.testDetectMotion(data, motion.inputs);
                logDetection log      = TheRuleTester.temp_log;
                //
                log.info = motion.name + " ( " + log.info + " )";
                if (detected)
                {
                    log.info = "[" + log.detectAt + "] " + log.info;
                }
                else
                {
                    log.info = "[X] " + log.info;
                }
                log_list.Add(log);
                matrix_data += "," + TheTool.convertBoolean_01(detected);
            }
            //--------------------------------
            TheSys.showError("File: " + currentFileName);
            foreach (logDetection s in log_list.OrderBy(o => o.detectAt).ThenBy(o => o.num_pose))
            {
                TheSys.showError(s.info);
            }
            TheSys.showError("---------------------");
            return(matrix_data);
        }
Ejemplo n.º 3
0
        public static logDetection temp_log = new logDetection();//temp data for show result

        //Check if a specific Motion is exist in Data
        //All Data - 1 Motion
        public static Boolean testDetectMotion(List <UKI_Data_AnalysisForm> data, List <m_If> list_rule_motion)
        {
            temp_log = new logDetection();
            Boolean pass_Motion = false;
            //-- Prepare Posture & Rule ------------------
            List <List <m_If> > list_posture = new List <List <m_If> >();
            List <m_If>         posture      = new List <m_If>();

            foreach (m_If rule in list_rule_motion)
            {
                if (rule.type == TheMapData.if_type_2Joint || rule.type == TheMapData.if_type_BasicPose ||
                    rule.type == TheMapData.if_type_Change || rule.type == TheMapData.if_type_TimeAfterPose ||
                    rule.type == TheMapData.if_type_SphereAngle || rule.type == TheMapData.if_type_FlexionAngle
                    )
                {
                    posture.Add(rule); //waiting will be the end of rules
                }
                if (rule.type == TheMapData.if_type_TimeAfterPose || rule == list_rule_motion.Last())
                {
                    list_posture.Add(posture); posture = new List <m_If>();
                }
            }
            //-- Test Data ------------------
            List <m_If>[] arr_posture        = list_posture.ToArray();
            int           current_posture_id = 0;
            List <m_If>   previous_posture   = new List <m_If>();
            int           time_wait          = 0;// = sec * fps

            if (arr_posture.Count() >= 1)
            {
                List <m_If> current_posture = arr_posture[0];
                Boolean     first_record    = true;
                foreach (UKI_Data_AnalysisForm row in data)
                {
                    Boolean pass_1Posture = testDetect1Posture(row, current_posture, ref time_wait);
                    //
                    if (pass_1Posture)
                    {
                        if (!first_record)
                        {
                            temp_log.info += ", ";
                        }
                        first_record     = false;
                        temp_log.info   += "P" + (current_posture_id + 1) + ":" + row.id;
                        previous_posture = current_posture;
                        current_posture_id++;
                        if (current_posture_id == arr_posture.Count())
                        {
                            //Already Pass All Posture
                            pass_Motion       = true;
                            temp_log.detectAt = row.id;
                            temp_log.num_pose = current_posture_id - 1;
                            break;
                        }
                        else
                        {
                            //Go the the next posture
                            current_posture = arr_posture[current_posture_id];
                        }
                    }
                    else if (current_posture_id > 0)
                    {
                        //new posture is not detected, check if previous posture is ended
                        Boolean pass_previousPoseture = testDetect1Posture(row, previous_posture, ref time_wait);
                        if (!pass_previousPoseture)
                        {
                            time_wait--;//if end then start counting down
                            //reset
                            if (time_wait <= 0)
                            {
                                current_posture_id = 0;
                            }
                        }
                    }
                }
            }
            return(pass_Motion);
        }