//Export shot info button was clicked private void btnExportShotInfo_Click(object sender, EventArgs e) { int shot_index = listBoxShots.SelectedIndex; if (shot_index >= 0) { //Savedialog is only allowed to save as XML saveFileDialog.Filter = "XML file|*.xml"; saveFileDialog.Title = "Export shot information as XML file"; // If the user opted to save and the filename is not an empty string if (saveFileDialog.ShowDialog(this) == DialogResult.OK && saveFileDialog.FileName != "") { //Create the XML-document and save it XmlDocument xml_doc = xml_creator.createShotsXML(shotdetector.DetectionMethod, shotdetector.DetectionArgs, video_manager.ShotList, saveFileDialog.FileName); String filename = saveFileDialog.FileName; try { xml_doc.Save(saveFileDialog.FileName); } //Saving the XML document failed, indicate this to user catch (XmlException ex) { MessageBox.Show("Failed to save file: " + ex.Message, "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
static void test(String test_results_path, String filename, String truth_filename, int method_to_test) { //Creeer kortere filename voor bestandsnaam String short_filename = filename.Split('\\')[filename.Split('\\').Length - 1]; //Creeer lijst met testargumenten TextWriter tw = new StreamWriter(test_results_path + "\\test_results_" + short_filename + "_" + method_to_test + ".txt"); List <object[]> args_list = new List <object[]>(); switch (method_to_test) { case 1: args_list = testMethod1Args(); break; case 2: args_list = testMethod2Args(); break; case 3: args_list = testMethod3Args(); break; case 4: args_list = testMethod4Args(); break; case 5: args_list = testMethod5Args(); break; case 6: args_list = testMethod6Args(); break; default: break; } //Test uitvoeren voor alle mogelijke argumenten ShotDetector sd = new ShotDetector(); Stopwatch sw = new Stopwatch(); List <Shot> shotlist = new List <Shot>(); XMLCreator xmlcreator = new XMLCreator(); XMLComparator xmlcomp = new XMLComparator(); long timepassed; double[] results; double recall, precision; foreach (object[] args in args_list) { //Meten van het detecteren van de shots sw.Reset(); sw.Start(); shotlist = sd.detectShotsStandAlone(method_to_test - 1, filename, args); sw.Stop(); timepassed = sw.ElapsedMilliseconds; //Aanmaken van XML op basis van shotlist XmlDocument own = xmlcreator.createShotsXML(method_to_test, args, shotlist, filename); XmlDocument truth = new XmlDocument(); truth.Load(truth_filename); //Bereken recall en precision results = xmlcomp.performanceMeasures(truth, own); recall = results[0]; precision = results[1]; //Schrijf naar output String diag = ""; foreach (object arg in args) { diag += arg.ToString() + ";"; } diag += timepassed + ";" + recall + ';' + precision; tw.WriteLine(diag); Debug.WriteLine(diag); } tw.Close(); }
static void test(String test_results_path, String filename, String truth_filename, int method_to_test) { //Creeer kortere filename voor bestandsnaam String short_filename = filename.Split('\\')[filename.Split('\\').Length - 1]; //Creeer lijst met testargumenten TextWriter tw = new StreamWriter(test_results_path + "\\test_results_" + short_filename + "_" + method_to_test + ".txt"); List<object[]> args_list = new List<object[]>(); switch (method_to_test) { case 1: args_list = testMethod1Args(); break; case 2: args_list = testMethod2Args(); break; case 3: args_list = testMethod3Args(); break; case 4: args_list = testMethod4Args(); break; case 5: args_list = testMethod5Args(); break; case 6: args_list = testMethod6Args(); break; default: break; } //Test uitvoeren voor alle mogelijke argumenten ShotDetector sd = new ShotDetector(); Stopwatch sw = new Stopwatch(); List<Shot> shotlist = new List<Shot>(); XMLCreator xmlcreator = new XMLCreator(); XMLComparator xmlcomp = new XMLComparator(); long timepassed; double[] results; double recall, precision; foreach (object[] args in args_list) { //Meten van het detecteren van de shots sw.Reset(); sw.Start(); shotlist = sd.detectShotsStandAlone(method_to_test-1, filename, args); sw.Stop(); timepassed = sw.ElapsedMilliseconds; //Aanmaken van XML op basis van shotlist XmlDocument own = xmlcreator.createShotsXML(method_to_test, args, shotlist, filename); XmlDocument truth = new XmlDocument(); truth.Load(truth_filename); //Bereken recall en precision results = xmlcomp.performanceMeasures(truth, own); recall = results[0]; precision = results[1]; //Schrijf naar output String diag = ""; foreach (object arg in args) { diag += arg.ToString() + ";"; } diag += timepassed + ";" + recall + ';' + precision; tw.WriteLine(diag); Debug.WriteLine(diag); } tw.Close(); }