private void frame_threading() { int i = 0; States current_states = new States(); current_states = States.start; fileName = Directory.GetFiles(@"" + folder_selected, "*.xed"); Console.WriteLine("Successful to get all file name"); if (fileName.Length < 1) { Console.WriteLine("No xed file in this folder"); return; } colorizer = new Colorizer(AaronRotateTan, CurrentKinectSensor.DepthStream.MaxDepth, CurrentKinectSensor.DepthStream.MinDepth); while (Is_running) { switch (current_states) { case States.start: Console.WriteLine("Start state .. .. .. "); single_file_name = System.IO.Path.GetFileNameWithoutExtension(fileName[i]); if (!Directory.Exists(folder_selected + "\\" + single_file_name)) Directory.CreateDirectory(folder_selected + "\\" + single_file_name); colorWriter = new VideoWriter(folder_selected + "\\" + single_file_name + "\\" + single_file_name + "_c.avi", 30, 640, 480, true); depthWriter = new VideoWriter(folder_selected + "\\" + single_file_name + "\\" + single_file_name + "_d.avi", 30, 640, 480, true); FileStream file_name = File.Open(@folder_selected + "\\" + single_file_name + "\\" + single_file_name + ".csv", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); skeWriter = new StreamWriter(file_name); // !!!! Detecting signer by the filename if (single_file_name.Contains("Michael")) colorizer.Angle = MichaelRotateTan; else if (single_file_name.Contains("Anita")) colorizer.Angle = AnitaRotateTan; else if (single_file_name.Contains("Aaron")) colorizer.Angle = AaronRotateTan; controler.Open_File(fileName[i]); System.Threading.Thread.Sleep(1000); old_frame_number_for_stop = 0; old_skeleton_frame_number_for_stop = 0; current_frame_number_for_stop = 0; current_skeleton_frame_number_for_stop = 0; PreColorFrameNumber = -1; PreDepthFrameNumber = -1; first_skeleton_frame_number = 0; FirstTimeStamp = long.MaxValue; current_states = States.running_start; break; case States.running_start: file_IsReady = true; timer.Start(); controler.Run_by_clik(); //controler.Run(); current_states = States.Isrunning; break; case States.Isrunning: Console.WriteLine("Isrunning states..."); System.Threading.Thread.Sleep(2000); if ((current_frame_number_for_stop == old_frame_number_for_stop) && (current_skeleton_frame_number_for_stop == old_skeleton_frame_number_for_stop)) { current_states = States.ending; timer.Stop(); waiting = 0; } old_frame_number_for_stop = current_frame_number_for_stop; old_skeleton_frame_number_for_stop = current_skeleton_frame_number_for_stop; break; case States.ending: Console.WriteLine("Is ending state......"); i++; CloseAllWriter(); System.Threading.Thread.Sleep(400); if (i >= fileName.Length) current_states = States.finished; else current_states = States.start; break; case States.finished: Console.WriteLine("Happy finished all file in this folder"); all_finished = true; break; default: break; } if (all_finished) break; } }
private void frame_threading() { int i = 0; States current_states = new States(); current_states = States.start; fileName = Directory.GetFiles(@"" + folder_selected, "*.xed"); Console.WriteLine("Successful to get all file name"); if (fileName.Length < 1) { Console.WriteLine("No xed file in this folder"); return; } colorizer = new Colorizer(AaronRotateTan, CurrentKinectSensor.DepthStream.MaxDepth, CurrentKinectSensor.DepthStream.MinDepth); while (Is_running) { switch (current_states) { case States.start: Console.WriteLine("Start state .. .. .. "); single_file_name = System.IO.Path.GetFileNameWithoutExtension(fileName[i]); if (!Directory.Exists(folder_selected + "\\" + single_file_name)) { Directory.CreateDirectory(folder_selected + "\\" + single_file_name); } colorWriter = new VideoWriter(folder_selected + "\\" + single_file_name + "\\" + single_file_name + "_c.avi", 30, 640, 480, true); depthWriter = new VideoWriter(folder_selected + "\\" + single_file_name + "\\" + single_file_name + "_d.avi", 30, 640, 480, true); FileStream file_name = File.Open(@folder_selected + "\\" + single_file_name + "\\" + single_file_name + ".csv", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); skeWriter = new StreamWriter(file_name); // !!!! Detecting signer by the filename if (single_file_name.Contains("Michael")) { colorizer.Angle = MichaelRotateTan; } else if (single_file_name.Contains("Anita")) { colorizer.Angle = AnitaRotateTan; } else if (single_file_name.Contains("Aaron")) { colorizer.Angle = AaronRotateTan; } controler.Open_File(fileName[i]); System.Threading.Thread.Sleep(1000); old_frame_number_for_stop = 0; old_skeleton_frame_number_for_stop = 0; current_frame_number_for_stop = 0; current_skeleton_frame_number_for_stop = 0; PreColorFrameNumber = -1; PreDepthFrameNumber = -1; first_skeleton_frame_number = 0; FirstTimeStamp = long.MaxValue; current_states = States.running_start; break; case States.running_start: file_IsReady = true; timer.Start(); controler.Run_by_clik(); //controler.Run(); current_states = States.Isrunning; break; case States.Isrunning: Console.WriteLine("Isrunning states..."); System.Threading.Thread.Sleep(2000); if ((current_frame_number_for_stop == old_frame_number_for_stop) && (current_skeleton_frame_number_for_stop == old_skeleton_frame_number_for_stop)) { current_states = States.ending; timer.Stop(); waiting = 0; } old_frame_number_for_stop = current_frame_number_for_stop; old_skeleton_frame_number_for_stop = current_skeleton_frame_number_for_stop; break; case States.ending: Console.WriteLine("Is ending state......"); i++; CloseAllWriter(); System.Threading.Thread.Sleep(400); if (i >= fileName.Length) { current_states = States.finished; } else { current_states = States.start; } break; case States.finished: Console.WriteLine("Happy finished all file in this folder"); all_finished = true; break; default: break; } if (all_finished) { break; } } }