//Calculation button for was clicked private void buttonCalculate_Click(object sender, EventArgs e) { try { //If neither of the files is null, try to execute calculation if (xml_truth != null && xml_video != null) { double[] results = xml_comparator.performanceMeasures(xml_truth, xml_video); labelRecallValue.Text = results[0].ToString(); labelPrecisionValue.Text = results[1].ToString(); } //One of the xml file is null - we shouldn't ever get here because of the GUI else { MessageBox.Show("The XML file(s) is/are not loaded", "Calc Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Calc failed, probably because of invalid XML file(s) catch (Exception ex) { MessageBox.Show("Something is wrong with the XML file(s). Are you sure you selected the right XML files?", "Calc 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(); }