Exemple #1
0
        //Ref: (2014) Sequential max-margin event detectors
        //Ref: ChairLearn
        //Ref: Graph-based representation learning for automatic human motion segmentation
        static public List <Performance> export_SegmentAnalysis(InstanceContainer container, string pathSave)
        {
            List <string>      list_output           = new List <string>();
            List <Performance> list_performanceByMID = new List <Performance>();

            try
            {
                list_output.Add("name,sid,mid," + performance_header + ",key,keyGT,keyJ");
                if (container.list_inst.Count() > 0)
                {
                    foreach (Instance inst in container.list_inst)
                    {
                        Performance p = performance_measure(inst);
                        performance_measure2(p);
                        string output = inst.name + "," + inst.subject_id + "," + inst.motion_id
                                        + "," + performance_Print(p)
                                        + "," + printKeyPose(inst.keyPose, " ")
                                        + "," + printKeyPoseGT(inst.keyPoseGT, " ")
                                        + "," + printKeyJump(inst.keyPoseJump, " ");
                        performance_AddData(list_performanceByMID, p);
                        list_output.Add(output);
                    }
                }
                //path_segmentByMotion
                TheTool.exportCSV_orTXT(pathSave, list_output, false);
            }
            catch (Exception ex) { TheSys.showError(ex); }
            return(list_performanceByMID);
        }
Exemple #2
0
 public static void container_reuse(InstanceContainer container_new, InstanceContainer container_old)
 {
     try
     {
         if (container_old != null)
         {
             for (int i = 0; i < container_new.list_inst.Count; i++)
             {
                 Instance p = container_old.list_inst.Find(s => s.path == container_new.list_inst[i].path);
                 if (p != null)
                 {
                     container_new.list_inst[i] = p;
                 }
             }
         }
     }
     catch (Exception ex) { TheSys.showError(ex.ToString()); }
 }
Exemple #3
0
        //show only indentity, load data only when perform analysis
        public static InstanceContainer loadInstanceList_fromDBoth_NoSubFolder(InstanceContainer inst_container_old, Boolean loadData, string path_db, string txt_filter, int skip)
        {
            InstanceContainer inst_container = new InstanceContainer();

            try
            {
                if (!Directory.Exists(path_db))
                {
                    TheSys.showError("Target folder is not exist: " + path_db); return(inst_container);
                }
                string[] inst_file = Directory.GetFiles(path_db, "*.csv");
                Array.Sort(inst_file);
                for (int i_i = 0; i_i < inst_file.Count(); i_i++)
                {
                    if (inst_file[i_i] == "" || inst_file[i_i].Contains(txt_filter))
                    {
                        Instance inst = new Instance();
                        inst.subject_id = 1;
                        inst.motion_id  = 1;
                        inst.path       = inst_file[i_i];
                        inst.name       = TheTool.getFileName_byPath(inst.path);
                        inst.skip       = skip;
                        if (loadData)
                        {
                            inst.getDataRaw(true);
                        }
                        inst_container.list_inst.Add(inst);
                        inst_container.list_sid.Add(1);
                        inst_container.list_mid.Add(1);
                    }
                }
            }
            catch (Exception ex) { TheSys.showError(ex); }
            container_reuse(inst_container, inst_container_old);
            return(inst_container);
        }
Exemple #4
0
        //show only indentity, load data only when perform analysis
        public static InstanceContainer loadInstanceList_fromDB(InstanceContainer inst_container_old, Boolean loadData, List <int> sid_list, List <int> mid_list)
        {
            InstanceContainer inst_container = new InstanceContainer();

            try
            {
                if (!Directory.Exists(path_database))
                {
                    TheSys.showError("Target folder is not exist: " + path_database); return(inst_container);
                }
                string[] subject_folder = Directory.GetDirectories(path_database);
                TheTool.sortList_StringWithNumeric(subject_folder);
                //
                int s_start = 0;
                int s_end   = subject_folder.Count();
                for (int s_i = s_start; s_i < s_end; s_i++)
                {
                    int s_current = TheTool.getInt(TheTool.getFileName_byPath(subject_folder[s_i]));
                    if (sid_list == null || sid_list.Contains(s_current))
                    {
                        string[] motion_folder = Directory.GetDirectories(subject_folder[s_i]);
                        TheTool.sortList_StringWithNumeric(motion_folder);
                        int m_start = 0;
                        int m_end   = motion_folder.Count();
                        for (int m_i = m_start; m_i < m_end; m_i++)
                        {
                            int m_current = TheTool.getInt(TheTool.getFileName_byPath(motion_folder[m_i]));
                            if (mid_list == null || mid_list.Contains(m_current))
                            {
                                string[] inst_file = Directory.GetFiles(motion_folder[m_i], "*.csv");
                                Array.Sort(inst_file);
                                for (int i_i = 0; i_i < inst_file.Count(); i_i++)
                                {
                                    Instance inst = new Instance();
                                    inst.subject_id = s_current;
                                    inst.motion_id  = m_current;
                                    inst.path       = inst_file[i_i];
                                    inst.name       = TheTool.getFileName_byPath(inst.path);
                                    if (loadData)
                                    {
                                        inst.getDataRaw(true);
                                    }
                                    inst_container.list_inst.Add(inst);
                                    if (inst_container.list_sid.Contains(s_current) == false)
                                    {
                                        inst_container.list_sid.Add(s_current);
                                    }
                                    if (inst_container.list_mid.Contains(m_current) == false)
                                    {
                                        inst_container.list_mid.Add(m_current);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { TheSys.showError(ex); }
            container_reuse(inst_container, inst_container_old);
            return(inst_container);
        }