static public void getMinMax_Euclidian() { try { min_euclidian = new double[10]; max_euclidian = new double[10]; //---------- listJoint = TheTool.getListJoint(""); listJoint_D = TheTool.getListJoint(col_suffix_d); List <double> d; int i = 0; foreach (string col in listJoint_D) { d = new List <double>(); for (int row = 0; row < dt_fullTable.Rows.Count; row++) { d.Add(double.Parse(dt_fullTable.Rows[row][col].ToString())); } max_euclidian[i] = d.Max(); min_euclidian[i] = d.Min(); i++; } minmax_Euclidian_ready = true; } catch { TheSys.showError("File must contain column e.g. 'Head_D'", true); TheSys.showError(">> P-Analysis & Concat files first.", true); } }
//Automatic change to original table static public void normalize_table_MinMax( DataTable dt, List <string> col_list, int digit) { try{ double v; double min = 0; double max = 0; double range = 0; List <double> d; // foreach (string col in col_list) { d = new List <double>(); for (int row = 0; row < dt.Rows.Count; row++) { d.Add(double.Parse(dt.Rows[row][col].ToString())); } max = d.Max(); min = d.Min(); range = max - min; // for (int row = 0; row < dt.Rows.Count; row++) { v = double.Parse(dt.Rows[row][col].ToString()); v = (v - min) / range; dt.Rows[row][col] = Math.Round(v, digit); } } } catch (Exception e) { TheSys.showError("Err: [" + processing_file + "] " + e.ToString(), true); } }
int frame_s = 10; //Frame Size : sec void prepareData() { try { report_data_35List.Clear(); int i = 0; int collected = 0; int a = frame_skip; foreach (DetectorReportData data in report_data) { if (collected >= show_Max) { break; } if (i >= show_startAt) { if (a == 0) { report_data_35List.Add(data); collected++; a = frame_skip; } else { a--; } } i++; } report_data_35List_array = report_data_35List.ToArray(); data_count = report_data_35List_array.Count(); } catch (Exception ex) { TheSys.showError("PrepareData: " + ex.Message); } }
public static void testData(int[] arr) { for (int i = 0; i < arr.Count(); i++) { TheSys.showError("_" + arr[i].ToString(), false); } }
private void butTF_Click(object sender, RoutedEventArgs e) { try { frame_skip = 0; int a = TheTool.getInt(txtTF.Text); if (a < 10) { frame_skip = 0; txtTF.Text = "10"; } else { while (a >= 20) { frame_skip++; a -= 10; } } //-------- int temp = frame_skip; frame_m = 0; frame_s = 0; while (temp >= 5) { temp -= 6; frame_m += 1; } while (temp >= 0) { temp -= 1; frame_s += 10; } //------- adjustGUI(); prepareData(); draw(); } catch (Exception ex) { frame_skip = 0; TheSys.showError("TimeFrame Error: " + ex.Message); } }
public static void instanceDB_fileRenaming() { try { string[] subject_folder = Directory.GetDirectories(path_database); for (int s_i = 0; s_i < subject_folder.Count(); s_i++) { string tag_subject = "{S" + TheTool.getTxt_Numeric_FillBy0(TheTool.getFileName_byPath(subject_folder[s_i]), 2) + "}"; string[] motion_folder = Directory.GetDirectories(subject_folder[s_i]); for (int m_i = 0; m_i < motion_folder.Count(); m_i++) { string tag_motion = "{M" + TheTool.getTxt_Numeric_FillBy0(TheTool.getFileName_byPath(motion_folder[m_i]), 2) + "} "; string[] inst_file = Directory.GetFiles(motion_folder[m_i], "*.csv"); for (int i_i = 0; i_i < inst_file.Count(); i_i++) { string path_oldFullPath = inst_file[i_i]; string path_directory = Path.GetDirectoryName(path_oldFullPath); string file_name = TheTool.getFileName_byPath(path_oldFullPath); string[] file_name_splitted = TheTool.splitText(file_name, "} "); string file_name_clean = file_name_splitted.Last(); //----------- string path_newFullPath = path_directory + @"\" + tag_subject + tag_motion + file_name_clean + ".csv"; System.IO.File.Move(path_oldFullPath, path_newFullPath); } } } } catch (Exception ex) { TheSys.showError(ex); } }
public static List <UKI_DataRaw> BVH_convert(String path_origin) { List <UKI_DataRaw> list_raw = new List <UKI_DataRaw>(); List <MocapNode[]> list_nodeSet = new List <MocapNode[]>(); try { List <string> data_origin = TheTool.read_File_getListString(path_origin); Boolean start = false; int row_i = 0; foreach (string row in data_origin) { if (start) { BVH_readRow(ref list_raw, ref list_nodeSet, row_i, row); row_i++; } if (!start && row.Contains("Frame Time")) { start = true; } } } catch (Exception ex) { TheSys.showError(ex); } //Scale = http://mocap.cs.cmu.edu/faqs.php : /.45 * 0.0254 TheUKI.UKI_DataRaw_scaling(ref list_raw, 0.05644444444444444444444444444444, 0); return(list_raw); }
public void editIf(m_If i_origin) { try { addNew = false; this.Title = "Edit Change-from-Initial Condition"; butAdd.Content = "Edit"; // comboJ1.Text = TheMapData.getJointDef(i_origin.v); this.i_origin = i_origin; int value = (int)(i_origin.value_d * 100); comboDirect.Text = TheMapData.moveMoveDirection_getDef_byAxisDirection(i_origin.axis, 1); if (value >= 0) { comboOpt.Text = TheMapData.convertOpt_getDef_byMath(i_origin.opt, false); txtValue.Text = value.ToString(); } else { comboOpt.Text = TheMapData.convertOpt_getDef_byMath(i_origin.opt, true); txtValue.Text = (-value).ToString(); } } catch (Exception ex) { TheSys.showError(ex); } }
//------------------ private void butAnalyze_Click(object sender, RoutedEventArgs e) { try { string folderPath = TheURL.url_saveFolder + "Analysis_" + DateTime.Now.ToString("ddHHmmssff"); string note_path = folderPath + @"\note.txt"; string matrix_path = folderPath + @"\Matrix.csv"; TheTool.Folder_CreateIfMissing(folderPath); List <String> matrix_data = new List <String>(); String matrix_Head = ""; foreach (m_Motion motion in list_motions) { matrix_Head += "," + motion.name; } matrix_data.Add(matrix_Head); //------------------- String path_RawData; foreach (DataRow r in dataTable.Rows) { try { path_RawData = r[col_path].ToString(); matrix_data.Add(motionAnalysis(path_RawData, folderPath, this.list_motions)); } catch (Exception ex) { TheSys.showError(r[col_path].ToString() + " : " + ex.ToString()); } } //-------------------- TheTool.exportCSV_orTXT(matrix_path, matrix_data, false); TheTool.exportFile(TheSys.getText_List(), note_path, false); System.Windows.MessageBox.Show(@"Save to '" + folderPath + "'", "Export Data"); } catch (Exception ex) { TheSys.showError(ex); } }
List <str2_double> getlistCorrelation() { List <str2_double> output = new List <str2_double>(); try { foreach (List <String> group in TheUKI.list_bodyGroup_full)//List of Redundantable { string[] feature = group.ToArray(); for (int i = 0; i < feature.Count(); i++) { string s1 = ""; string s2 = ""; if (i == feature.Count() - 1) { s1 = feature[i]; s2 = feature[0]; } else { s1 = feature[i]; s2 = feature[i + 1]; } str2_double new_data = new str2_double(); new_data.str1 = s1; new_data.str2 = s2; new_data.v = TheTool.LinearRegression_Cal_Correlation(this.dt_raw_exclude, s1, s2); output.Add(new_data); } } } catch (Exception ex) { TheSys.showError(ex); } return(output); }
void export_Split() { try { int aa_start = TheTool.getInt(txtAAstart); int aa_range = TheTool.getInt(txtAARange); if (aa_range == 0) { checkAutoArrange.IsChecked = false; } int aa_i = 0; int aa_i_max = TheTool.getPartition(splitter.Count, aa_range); //-------- foreach (int[] split in splitter) { DataTable dt_split = TheTool.dataTable_selectRow_byIndex(dataTable, split[0], split[1]); string save_path = TheURL.url_saveFolder; if (checkAutoArrange.IsChecked.Value) { save_path += @"\" + (aa_start + aa_i); TheTool.Folder_CreateIfMissing(save_path); } save_path += @"\" + fileName + " (" + split[0] + "-" + split[1] + ").csv"; TheTool.export_dataTable_to_CSV(save_path, dt_split); aa_i++; if (aa_i >= aa_i_max) { aa_i = 0; } } System.Windows.MessageBox.Show(@"Save to '" + TheURL.url_saveFolder + "'", "Export CSV"); txtAAstart.Text = (aa_start + aa_i_max).ToString(); } catch (Exception ex) { TheSys.showError(ex); } }
public void getMainTable_byPathTable(DataTable dt) { try { resetMainTable(); int fieldID = 0; //---------- foreach (DataRow r in dt.Rows) { mainTable_getEachRecord(fieldID, r[col_path].ToString()); fieldID++; if (saveSubTable == true) { save_SubTable(); } } //---------- //calSuperNormal(); //check error if (showSample == true) { TheTool.showTable(this.sub_table, "Sample - each file", "sample"); } } catch (Exception e) { TheSys.showError(e.ToString(), true); } }
//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); }
//input : data with header (abs = absolute) //output has header public static List <String> process_calChange(DataTable dt, Boolean abs, Boolean sort) { List <String> result = new List <String>(); try { int row_i = 0; foreach (DataRow row in dt.Rows) { if (row_i > 1) { result.Add(""); } if (row_i > 0) { List <PE_Feature> list_feature = new List <PE_Feature>(); foreach (DataColumn col in dt.Columns) { PE_Feature feature = new PE_Feature(); feature.head = col.ColumnName; feature.bef = TheTool.getDouble(dt.Rows[row_i - 1][col].ToString()); feature.after = TheTool.getDouble(dt.Rows[row_i][col].ToString()); if (abs) { feature.change = Math.Abs(feature.after - feature.bef); } else { feature.change = feature.after - feature.bef; } list_feature.Add(feature); } if (sort) { var sortList = list_feature.OrderByDescending(pd => pd.change).ToArray(); list_feature = sortList.ToList(); } String r1 = ""; String r2 = "Base"; String r3 = "Pose " + row_i; String r4 = "Change"; foreach (PE_Feature f in list_feature) { r1 += "," + f.head; r2 += "," + f.bef; r3 += "," + f.after; r4 += "," + f.change; } result.Add(r1); result.Add(r2); result.Add(r3); result.Add(r4); } row_i++; } } catch (Exception ex) { TheSys.showError("Normal: " + ex.ToString()); } return(result);//New Table }
private void butHelp_Click(object sender, RoutedEventArgs e) { TheSys.showError("Input: (Dynamic Format)"); TheSys.showError("Process [CheckError]: For all files, check if the total number of column is equal to expected"); TheSys.showError("Process [Col Del]: For all files, delete specific column"); TheSys.showError("Process [File name Coder]: Random sort and rename to climinate bias before testing"); TheSys.showError("Process [Col Del]: For all files, delete all columns those are not match the List"); }
//** ERROR ** static public string classify() { try { Instances inst = TheWeka.createInstance(path_file_test); return(TheWeka.do_Classification_bySerialClassfier_1out_standAlone(classifier, inst, colClass)); } catch (Exception ex) { TheSys.showError(ex.ToString(), true); return(""); } }
//path_data : row are selected, 2 columns to be cropped ("time,id") //path_minmax : minmax, no crop is needed, leave "" for local MM //path_folder & filename : path to save //Auto Crop Column Name public static void ChangeAnalysis(string path_data_selected, string path_GlobalMM, string path_folder, string filename) { try { path_PE_localMM = path_folder + @"\[MinMax(local)].csv";//in case Local path_PE_vRank = path_folder + @"\" + filename + " F-Rank.csv"; path_PE_normal_extract = path_folder + @"\" + filename + " Extracted-03 Normalized.csv"; DataTable dt_temp = CSVReader.ReadCSVFile(path_data_selected, true); //have 2 unused col DataTable dt_data = TheTool.dataTable_cropCol(dt_temp, 2, 0); //only analyzed column DataTable dt_mm = null; //Datatable of MinMax //--- Prepare MinMax Table Boolean useGlobalMM = true; if (path_GlobalMM == "" || File.Exists(path_GlobalMM) == false) { useGlobalMM = false; } else { try { dt_mm = CSVReader.ReadCSVFile(path_GlobalMM, true); } catch (Exception ex) { TheSys.showError(ex); useGlobalMM = false; } } if (useGlobalMM == false) { //build MM table by local data dt_mm = TheTool.dataTable_getMaxMinTable(dt_data);//generate MM table TheTool.export_dataTable_to_CSV(path_PE_localMM, dt_mm); } try { DataTable dt_normal = TheTool.dataTable_MinMaxNormalization(dt_data, dt_mm); //--- Cal Change ------------------------------------- List <String> data_raw_change = ThePosExtract.process_calChange(dt_data, false, false); List <String> data_normal_change = ThePosExtract.process_calChange(dt_normal, true, true); List <String> data_ChangeAnalysis = new List <String>(); data_ChangeAnalysis.Add("RAW"); data_ChangeAnalysis.AddRange(data_raw_change); data_ChangeAnalysis.Add(""); data_ChangeAnalysis.Add(""); data_ChangeAnalysis.Add("NORMALIZED F-RANKING"); data_ChangeAnalysis.AddRange(data_normal_change); TheTool.exportCSV_orTXT(path_PE_vRank, data_ChangeAnalysis, false); //--- Normalize Table : re-added column before save dt_normal.Columns.Add("time", typeof(string)).SetOrdinal(0); dt_normal.Columns.Add("id", typeof(string)).SetOrdinal(0); int r = 0; foreach (DataRow row in dt_normal.Rows) { row[0] = dt_temp.Rows[r][0].ToString(); row[1] = dt_temp.Rows[r][1].ToString(); r++; } TheTool.export_dataTable_to_CSV(path_PE_normal_extract, dt_normal); } catch (Exception ex) { TheSys.showError("Normalize: " + ex.ToString()); } } catch (Exception ex) { TheSys.showError("Change Analysis: " + ex.ToString()); } }
// "saveFolder" end with \ public static void calSparse(List <UKI_DataRaw> list_extractPose, string saveFolder, string filename) { try { List <String> list_data_n1 = new List <String> { }; List <String> list_data_n2 = new List <String> { }; List <String> list_data_n3 = new List <String> { }; UKI_DataRaw pose_canonical = null; UKI_DataRaw pose_current = null; list_data_n1.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType())); list_data_n2.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType())); list_data_n3.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType())); int index_canonical = 0; int index_current = 0; String row_name; foreach (UKI_DataRaw r in list_extractPose) { pose_current = r; index_current = r.id; //---------------------------------------------------- String data = ""; if (pose_canonical != null) { row_name = index_canonical + " to " + index_current + ","; double duration_frame_inverse = 1.0f / (pose_current.id - pose_canonical.id); double[] joint_sum = SummarizeJointsVector(pose_current); data = row_name + DisplayJointsVectorToCentroid(pose_current, joint_sum, duration_frame_inverse, pose_canonical); list_data_n1.Add(data); UKI_DataRaw joint_vector_s_1 = CreateSkeletonRawDataFromString(data); double[] xyz_size_vector_current_pose = JointToJointSize(joint_vector_s_1); double[] xyz_size_vector_canonical_pose = JointToJointSize(pose_canonical); data = row_name + DisplayJointsVectorRescalling(joint_vector_s_1, xyz_size_vector_canonical_pose, xyz_size_vector_current_pose); list_data_n2.Add(data); UKI_DataRaw joint_vector_s_2 = CreateSkeletonRawDataFromString(data); double[] joint_sum_canonical_ht = SummarizeJointsVectorFromHeadAndTorso(pose_canonical); double[] joint_sum_current_ht = SummarizeJointsVectorFromHeadAndTorso(joint_vector_s_2); data = row_name + DisplayJointsVectorHeadAndTorsoToCentroid(joint_vector_s_2, joint_sum_canonical_ht, joint_sum_current_ht, duration_frame_inverse); list_data_n3.Add(data); } //---------------------------------------------------- pose_canonical = r; index_canonical = r.id; } TheTool.exportCSV_orTXT(saveFolder + "N1_" + filename + ".csv", list_data_n1, false); TheTool.exportCSV_orTXT(saveFolder + "N2_" + filename + ".csv", list_data_n2, false); TheTool.exportCSV_orTXT(saveFolder + "N3_" + filename + ".csv", list_data_n3, false); } catch (Exception ex) { TheSys.showError(ex); } }
public static void MSR_showSample() { TheSys.showError("Link: http://research.microsoft.tcom/en-us/um/people/zliu/ActionRecoRsrc/default.htm"); TheSys.showError("Below is an example of data"); TheSys.showError(""); foreach (String s in TheTool.read_File_getListString(TheURL.url_tv_sample_msr)) { TheSys.showError(s); } }
private void butViewColList_Click(object sender, RoutedEventArgs e) { string txt = ""; foreach (string t in natureColumn) { txt += t + System.Environment.NewLine; } TheSys.showError(txt, true); }
private void msr_sample_Click(object sender, RoutedEventArgs e) { TheConverter.MSR_showSample(); TheSys.showError("Link: http://research.microsoft.tcom/en-us/um/people/zliu/ActionRecoRsrc/default.htm"); TheSys.showError("Below is an example of data"); TheSys.showError(""); foreach (String s in TheTool.read_File_getListString(TheURL.url_tv_sample_msr)) { TheSys.showError(s); } }
//Cascade Calculation static public double calAngle_3D_fromTemp(int baseSide) { double targetDegree = 0; try { targetDegree = Math.Acos(getBaseSide(baseSide) / temp_deltaR); targetDegree = targetDegree * math_pi_180; } catch (Exception e) { TheSys.showError("Err cal3D_Temp: " + e.ToString(), true); } return(targetDegree); }
public static void showError(int[] i_arr) { for (int a = 0; a < i_arr.Count(); a++) { if (a > 0) { TheSys.showError(",", false); } showError(i_arr[a] + "", false); } TheSys.showError(""); }
public static void readSetting() { try { List <string> stringList = TheTool.read_File_getListString(TheURL.url_config); foreach (string s in stringList) { storeSetting(s); } loadSetting = true; } catch { TheSys.showError("Error Read Setting : delete config.txt to solve this problem"); } }
void initialize() { try { TheURL.url_0_root = AppDomain.CurrentDomain.BaseDirectory; TheURL.url_config = TheURL.url_0_root + TheURL.url_config; MySetting.readSetting(); TheURL.initializeURL(); TheURL.initializeURL_permanent(); TheProlongSitDetector.initializePath(); } catch { TheSys.showError("Initializ. Error"); } }
public void setPath(string path) { try { List <string> stringList = new List <string>() { }; stringList.Add(path); TheTool.writeFile(stringList, TheURL.url_config_FTG, false); path_fightingICE = path; } catch { TheSys.showError("Error Save Setting"); } }
//================================================================= void loadData() { container.list_inst.Clear(); foreach (DataRow r in dataTable.Rows) { try { string path_raw = r[col_path].ToString(); container.list_inst.Add(TheInstanceContainer.load1Instance_fromPath(path_raw)); } catch (Exception ex) { TheSys.showError(ex); } } }
static public void loadComPort(Boolean showError) { try { list_port = SerialPort.GetPortNames(); selectPort = list_port.Last(); } catch (Exception e) { if (showError == true) { TheSys.showError("micro:" + e.Message, true); connected = false; } } }
//testing double[] public static void testData(double[,] arr) { int bound0 = arr.GetUpperBound(0);//last existng # int bound1 = arr.GetUpperBound(1); for (int i = 0; i <= bound0; i++) { for (int x = 0; x <= bound1; x++) { TheSys.showError(arr[i, x].ToString()); } } }
//******************************************************************************************* //***************** Angle Translation ******************************************************* static public double calAngle_3D(SkeletonPoint joint1, SkeletonPoint joint2, int baseSide1, int baseSide2) { double targetDegree = 0; try { double[] j1 = { joint1.X, joint1.Y, joint1.Z }; double[] j2 = { joint2.X, joint2.Y, joint2.Z }; targetDegree = calAngle_3D_byDouble(j1, j2, baseSide1, baseSide2); } catch (Exception e) { TheSys.showError("Err cal3D: " + e.ToString(), true); } return(targetDegree); }