//The Main Function //public static void AnalyzeAll(MainWindow _mw, object o_filepath, int record_id) //{ // string filepath = (string)o_filepath; // List<FileNames> Filelist = new List<FileNames>(); // GetSystemAllPath.GetallDirectory(Filelist,filepath); // for(int i = 0; i < Filelist.Count(); i++ ) // { // string timeFolder = filepath +"\\"+ Filelist[i].text; // //Thread ScanFolderThread = new Thread(ScanFolder); // //ScanFolderThread.Start(timeFolder); // //Console.WriteLine("Analyzing " + timeFolder + ".....\n"); // mw.DebugWriteLine("开始分析" + timeFolder + "..."); // ScanFolder(timeFolder, record_id); // } //} //Scan one folder for time //public static void ScanFolder(object o_filepath, int record_id) //{ // string filepath = (string)o_filepath; // string CalResFolder = filepath + "\\CalResult"; // //string EncodeFolder = filepath + "\\EncodeResult"; // string EncodeFolder = filepath; // //Thread ScanCalThread = new Thread(ScanCalResult); // //Thread ScanEncThread = new Thread(ScanEncodeResult); // //ScanCalThread.Start(CalResFolder); // //ScanEncThread.Start(EncodeFolder); // ScanCalResult(CalResFolder, record_id); // ScanEncodeResult(EncodeFolder, record_id); //} //Deal with CalResult public static void ScanCalResult(object o_filepath, string metercsv, int record_id) { string filepath = (string)o_filepath; int extra_file_count = 0; List <FileNames> Filelist = new List <FileNames>(); GetSystemAllPath.GetallDirectory(Filelist, filepath); if (Filelist.Count() < 1) { mw.DebugWriteLine("未发现数据文件"); return; } // Analyze csv result for (int i = 0; i < Filelist.Count(); i++) { string csvpath = filepath + "\\" + Filelist[i].text; //Console.WriteLine("---Analyzing " + Filelist[i].text + ".....\n"); mw.DebugWriteLine("分析数据文件" + Filelist[i].text + "..."); CSVHandler.HandleCSVParam hcsv_param; hcsv_param.record_id = record_id; hcsv_param.filepath = csvpath; hcsv_param.mw = mw; // Handle the csv-Result //CSVHandler.HandleCSV(hcsv_param); // Handle the csv-Result mtd Thread HandleCSV_thread = new Thread(CSVHandler.HandleCSV); HandleCSV_thread.Start(hcsv_param); // Handle the csv-Result mtd and multi-line //Thread HandleCSV_thread = new Thread(CSVHandler.HandleCSV_multiLine); //HandleCSV_thread.Start(hcsv_param); } // Analyze mileage result if (File.Exists(metercsv)) { extra_file_count++; mw.DebugWriteLine("分析里程记录文件" + metercsv); CSVHandler.HandleMileageParam hmil_param; hmil_param.csv_file_path = metercsv; hmil_param.record_id = record_id; hmil_param.mw = mw; Thread HandleMil_thread = new Thread(CSVHandler.HandleMileage); HandleMil_thread.Start(hmil_param); } // Waiting for all threads work done while (threadControlCounter < (Filelist.Count() + extra_file_count)) { mw.SubProcessReport(mw.line_counter); Thread.Sleep(100); } threadControlCounter = 0; // mw.DebugWriteLine("分析数据文件" + Filelist[i].text + "完成"); }
//Deal with EncodeResult public static void ScanEncodeResult(object o_filepath, int record_id) { string filepath = (string)o_filepath; string EncodeResult = filepath + "\\EncodeResult"; List <FileNames> Filelist = new List <FileNames>(); GetSystemAllPath.GetallDirectory(Filelist, EncodeResult); //Console.WriteLine("---Decoding " + EncodeResult + ".....\n"); if (Filelist.Count() < 1) { mw.DebugWriteLine("未发现视频文件"); return; } mw.DebugWriteLine("解析视频目录" + EncodeResult + "..."); for (int i = 0; i < Filelist.Count(); i++) { string mjpegpath = EncodeResult + "\\" + Filelist[i].text + "\\" + Filelist[i].children[0].text; string outputpath = filepath + "\\DecodeResult\\" + Filelist[i].text; //Console.WriteLine("------Decoding " + Filelist[i].text + ".....\n"); mw.DebugWriteLine("解析视频文件" + Filelist[i].text + "..."); //Decode the mjpeg MjpegHandler.DecodeParam param; param.inputvideo = mjpegpath; param.outputpath = outputpath; Thread DecodeThread = new Thread(MjpegHandler.CallPythonToDecode); DecodeThread.Start(param); //MjpegHandler.CallPythonToDecode(param); } mw.DebugWriteLine("导入视频序列" + EncodeResult + "..."); for (int i = 0; i < Filelist.Count(); i++) { mw.DebugWriteLine("导入视频序列" + Filelist[i].text + "..."); string image_root_url = filepath + "\\DecodeResult\\" + Filelist[i].text; string mjpeg_csv_path = EncodeResult + "\\" + Filelist[i].text + "\\" + Filelist[i].children[1].text; // Get CameraNum from filename int cam_num = ConfigHandler.GetCameraNum(Filelist[i].children[1].text.Split("_")[1].Split(".")[0].ToCharArray()); if (cam_num < 1 || cam_num == 999) { continue; } CSVHandler.HandleTimestampParam htime_param; htime_param.record_id = record_id; htime_param.cam_num = cam_num; htime_param.csv_file_path = mjpeg_csv_path; htime_param.mjpeg_root_path = image_root_url; htime_param.mw = mw; // Handle Timestamp csv //CSVHandler.HandleTimestamp(htime_param); // Handle Timestamp csv mtd Thread htime_thread = new Thread(CSVHandler.HandleTimestamp); htime_thread.Start(htime_param); // mw.DebugWriteLine("导入视频序列" + Filelist[i].text + "完成"); } mw.DebugWriteLine("导入视频序列" + EncodeResult + "完成"); while (threadControlCounter < (Filelist.Count() * 2)) { int task_now = (int)(GetSystemAllPath.GetDirectorySize(filepath + "\\DecodeResult") / 1000000); mw.SubProcessReport(task_now + mw.line_counter); Thread.Sleep(100); } threadControlCounter = 0; //Console.WriteLine("---Decoding Finished " + EncodeResult + ".....\n"); mw.DebugWriteLine("解析视频目录" + EncodeResult + "完成"); }