Example #1
0
        public static void EvaluateRectObjects(string gt_dir, string auto_dir)
        {
            int gt_count_total = 0, auto_count_total = 0, matched_count_total = 0;

            string[] gt_xml_files = Directory.GetFiles(gt_dir, "*.xml");
            using (StreamWriter sw = new StreamWriter("Evaluation.txt"))
            {
                sw.WriteLine("FigureName\tGT Panels\tAuto Panels\tMatched Panels");
                for (int i = 0; i < gt_xml_files.Length; i++)
                {
                    string gt_xml_file   = gt_xml_files[i];
                    string auto_xml_file = Path.Combine(auto_dir, Path.GetFileName(gt_xml_file).Replace("_data.xml", ".xml"));
                    if (!File.Exists(auto_xml_file))
                    {
                        continue;
                    }

                    iPhotoDrawAnnotation        gt_annotation   = new iPhotoDrawAnnotation(); gt_annotation.LoadRectObjects(gt_xml_file);
                    PanelSegmentationAnnotation auto_annotation = new PanelSegmentationAnnotation(); auto_annotation.LoadRectObjects(auto_xml_file);

                    int gt_count, auto_count, matched_count;
                    ObjectAnnotation.EvaluateRectObjects(gt_annotation, auto_annotation, out gt_count, out auto_count, out matched_count);
                    sw.WriteLine("{0}\t{1}\t{2}\t{3}", gt_annotation.figureFilename, gt_count, auto_count, matched_count);

                    gt_count_total      += gt_count;
                    auto_count_total    += auto_count;
                    matched_count_total += matched_count;
                }

                double recall    = (double)matched_count_total / (double)gt_count_total;
                double precision = (double)matched_count_total / (double)auto_count_total;
                double fscore    = 2 * precision * recall / (precision + recall);

                sw.WriteLine("Total\t{0}\t{1}\t{2}", gt_count_total, auto_count_total, matched_count_total);
                sw.WriteLine("Precision is {0}", precision);
                sw.WriteLine("Recall is {0}", recall);
                sw.WriteLine("FScore is {0}", fscore);
            }
        }