static DescriptorData ReadFile(String filename, String descriptor, String imageName) { DescriptorData dscData = new DescriptorData(); dscData.image = imageName; dscData.descriptor = descriptor; try { // Open the text file using a stream reader. String[] lines = File.ReadAllLines(filename); if (lines.Length > 1) { String[] values = lines[0].Split(null); dscData.correctMatches = Int32.Parse(values[0]); dscData.totalMatches = Int32.Parse(values[1]); dscData.pointData = new List <DescriptorData.PointData>(); for (int i = 1; i < lines.Length; i++) { DescriptorData.PointData data = new DescriptorData.PointData(); values = lines[i].Split(null); float correct = Int32.Parse(values[0]); float total = Int32.Parse(values[1]); data.correct = correct; data.total = total; dscData.pointData.Add(data); } for (int i = 0; i < dscData.pointData.Count; i++) { DescriptorData.PointData data = dscData.pointData[i]; // First check if there are 0 correct matches if (data.correct == 0) { data.recall = 0; data.precision = 1; } else { // Calculate the precision and make sure // that the toal matches are greater than 0, but they // really always should be... if (dscData.totalMatches > 0) { data.recall = data.correct / dscData.totalMatches; } else { data.recall = 1; } // Calculate the recall if (data.total > 0) { data.precision = data.correct / data.total; } else { data.precision = 0; } } globalScaleMax = Math.Max(globalScaleMax, data.recall); dscData.pointData[i] = data; } } } catch (Exception e) { Console.WriteLine("The file could not be read: "); Console.WriteLine(e.Message); } return(dscData); }
static DescriptorData ReadFile(String filename, String descriptor, String imageName) { DescriptorData dscData = new DescriptorData(); dscData.image = imageName; dscData.descriptor = descriptor; try { // Open the text file using a stream reader. String[] lines = File.ReadAllLines(filename); if(lines.Length > 1) { String[] values = lines[0].Split(null); dscData.correctMatches = Int32.Parse(values[0]); dscData.totalMatches = Int32.Parse(values[1]); dscData.pointData = new List<DescriptorData.PointData>(); for(int i = 1; i < lines.Length; i++) { DescriptorData.PointData data = new DescriptorData.PointData(); values = lines[i].Split(null); float correct = Int32.Parse(values[0]); float total = Int32.Parse(values[1]); data.correct = correct; data.total = total; dscData.pointData.Add(data); } for (int i = 0; i < dscData.pointData.Count; i++) { DescriptorData.PointData data = dscData.pointData[i]; // First check if there are 0 correct matches if(data.correct == 0) { data.recall = 0; data.precision = 1; } else { // Calculate the precision and make sure // that the toal matches are greater than 0, but they // really always should be... if(dscData.totalMatches > 0) { data.recall = data.correct / dscData.totalMatches; } else { data.recall = 1; } // Calculate the recall if (data.total > 0) { data.precision = data.correct / data.total; } else { data.precision = 0; } } globalScaleMax = Math.Max(globalScaleMax, data.recall); dscData.pointData[i] = data; } } } catch (Exception e) { Console.WriteLine("The file could not be read: "); Console.WriteLine(e.Message); } return dscData; }