private void ExtractFrames(TrainingVideo video) //extract frames from a particular training video { FramesToExtractDialog dialog = new FramesToExtractDialog(); //first ask the user how many frames to extract if (dialog.ShowDialog() == true) { CurrentProject.FramesToExtract = dialog.FramesToExtractTextBox.Text; UpdateFramesToExtract(); FileSystemUtils.WaitForFile(CurrentProject.ConfigPath); string filePath = EnvDirectory + "\\vdlc_extract_frames.py"; FileSystemUtils.MurderPython(); FileSystemUtils.RenewScript(filePath, AllScripts.ExtractFrames); //run DLC's extract_frames function using a script FileSystemUtils.ReplaceStringInFile(filePath, "config_path_identifier", CurrentProject.ConfigPath); //set function parameters FileSystemUtils.ReplaceStringInFile(filePath, "video_path_identifier", video.Path); Process p = new Process(); //prepare a cmd process to run the script ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "cmd.exe"; info.RedirectStandardInput = true; info.UseShellExecute = false; info.Verb = "runas"; info.CreateNoWindow = !ReadShowDebugConsole(); //if show debug console = true, then create no window has to be false p.EnableRaisingEvents = true; p.Exited += (sender1, e1) => //once done, continue to labeling the video automatically { LabelFrames(video); }; p.StartInfo = info; p.Start(); using (StreamWriter sw = p.StandardInput) { //run the script using the command line if (sw.BaseStream.CanWrite) { sw.WriteLine(Drive); sw.WriteLine("cd " + EnvDirectory); sw.WriteLine(FileSystemUtils.CONDA_ACTIVATE_PATH); sw.WriteLine("conda activate " + EnvName); sw.WriteLine("ipython vdlc_extract_frames.py"); if (info.CreateNoWindow == false) //for debug purposes { sw.WriteLine("ECHO WHEN YOU'RE DONE, CLOSE THIS WINDOW"); p.WaitForExit(); sw.WriteLine("Done, exiting."); } } } } else { EnableInteraction(); } }
private void ExtractFramesClicked(object sender, RoutedEventArgs e) //old function { var selectedVid = (TrainingVideo)TrainingListBox.SelectedItem; if (selectedVid != null) { BarInteraction(); FramesToExtractDialog dialog = new FramesToExtractDialog(); if (dialog.ShowDialog() == true) { CurrentProject.FramesToExtract = dialog.FramesToExtractTextBox.Text; UpdateFramesToExtract(); FileSystemUtils.WaitForFile(CurrentProject.ConfigPath); ExtractFrames(selectedVid); } else { EnableInteraction(); } } }