Exemplo n.º 1
0
        static void Main(string[] args)
        {
            List <OxyColor> colorTemp = new List <OxyColor>();

            colorTemp.Add(OxyColor.FromRgb(255, 127, 14));
            colorTemp.Add(OxyColor.FromRgb(214, 39, 40));
            colorTemp.Add(OxyColor.FromRgb(148, 103, 189));
            colorTemp.Add(OxyColor.FromRgb(44, 160, 44));
            colorTemp.Add(OxyColor.FromRgb(31, 119, 180));
            colorTemp.Add(OxyColor.FromRgb(227, 119, 194));
            colorTemp.Add(OxyColor.FromRgb(188, 189, 34));
            colorTemp.Add(OxyColor.FromRgb(140, 86, 75));
            colorTemp.Add(OxyColor.FromRgb(127, 127, 127));
            colorTemp.Add(OxyColor.FromRgb(23, 190, 207));

            colors = colorTemp.ToArray();

            Dictionary <String, ImagePlot> graphs = new Dictionary <String, ImagePlot>();

            // Minimum command line argument is the path to a descriptor
            if (args.Length < 1)
            {
                Console.WriteLine("Must specify file path as first argument. Run with --help for usage insructions.");

                return;
            }

            // Parse the argument list
            arguments = new Arguments();
            if (!Parser.Default.ParseArguments(args, arguments))
            {
                Console.WriteLine("Illegal arguments. Run with --help for usage instructions.");

                return;
            }


            // If the directory exists, go to each image (or the images that are listed)
            if (Directory.Exists(arguments.DocumentRoot))
            {
                // Get a list of the subdirectories
                String[] subDirectories = Directory.GetDirectories(arguments.DocumentRoot);
                for (int i = 0; i < subDirectories.Length; i++)
                {
                    String imageName = Path.GetFileName(subDirectories[i]);

                    bool runImage = true;
                    if (arguments.Images != null)
                    {
                        runImage = false;
                        foreach (String s in arguments.Images)
                        {
                            if (s.Equals(imageName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                runImage = true;
                                break;
                            }
                        }
                    }

                    if (runImage)
                    {
                        if (arguments.Verbose)
                        {
                            Console.WriteLine("Processing image: " + imageName);
                        }
                        DescriptorData[] datas = ProcessImage(imageName, subDirectories[i]);

                        // Add the datas to the graph objects
                        foreach (DescriptorData data in datas)
                        {
                            String key = data.image;
                            if (arguments.Flip)
                            {
                                key = data.descriptor;
                            }

                            if (!graphs.ContainsKey(key))
                            {
                                graphs.Add(key, new ImagePlot(key));
                            }

                            ImagePlot plot = graphs[key];
                            plot.descriptors.Add(data);
                        }
                    }
                }

                // Graph the data
                foreach (var item in graphs)
                {
                    GenerateGraph(item.Value);
                }

                ProcessReport(graphs.Values.ToArray());
            }
            else
            {
                Console.WriteLine("Image diretory is invalid!");
                return;
            }

            // Make the report with the image data.
            // ProcessReport(datas.ToArray());

            if (arguments.Verbose)
            {
                Console.WriteLine("Done!");
            }

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void ProcessReport(ImagePlot[] imageData)
        {

            String fileName = "Output.pdf";

            if(arguments.Output != null)
            {
                fileName = arguments.Output;
            }

            try
            {
                var s = File.Create(fileName);
                var r = new Report();
                r.AddHeader(1, "Output generated: "+DateTime.Now);

                int numReports = arguments.Graphs;
                int height = 0;
                switch (numReports)
                {
                    case 1:
                        height = 800;
                        break;
                    case 2:
                        height = 600;
                        break;
                    default:
                        height = 400;
                        break;
                }

                foreach(ImagePlot data in imageData)
                {
                    r.AddPlot(data.plot, null, 800, height);
                }

                //if (arguments.Raw && false)
                //{
                //    //r.AddParagraph()
                //    r.AddParagraph("this is a test");
                //}

                using (var w = new PdfReportWriter(s))
                {
                    w.WriteReport(r, new ReportStyle {});
                    if (arguments.Verbose) Console.WriteLine("Output to: " + fileName);
                }
            } 
            catch (Exception e)
            {
                Console.WriteLine("Could not output to file: " + e.Message);
            }
            
            
        }
Exemplo n.º 3
0
        static void GenerateGraph(ImagePlot plot)
        {
            PlotModel model = new PlotModel {
                Title = plot.name
            };

            model.LegendTitle = "Descriptor";
            if (arguments.Flip)
            {
                model.LegendTitle = "Image";
            }

            float maxPrecision = 0;
            int   colorIndex   = 0;

            foreach (DescriptorData data in plot.descriptors)
            {
                String title = data.descriptor;
                if (arguments.Flip)
                {
                    title = data.image;
                }

                title += " (" + data.correctMatches + "/" + data.totalMatches + ")";


                LineSeries line = new LineSeries {
                    Title = title, Color = colors[colorIndex++ % colors.Length]
                };
                for (int i = 0; i < data.pointData.Count; i++)
                {
                    maxPrecision = Math.Max(maxPrecision, data.pointData[i].precision);
                    line.Points.Add(new DataPoint(data.pointData[i].precision, data.pointData[i].recall));
                }
                model.Series.Add(line);
            }

            // If global scale is on, we'll use that instead.
            if (arguments.GlobalScale)
            {
                maxPrecision = globalScaleMax;
            }

            // Add some padding
            maxPrecision = (float)Math.Min(maxPrecision + (maxPrecision * .2), 1.2f);

            // If we aren't scaling, just set it to 1.0
            if (!arguments.Scale && !arguments.GlobalScale)
            {
                maxPrecision = 1.0f;
            }

            LineAnnotation max = new LineAnnotation {
                Type = LineAnnotationType.Vertical, X = 1.0, Color = OxyColors.LightGray, LineStyle = OxyPlot.LineStyle.Dash
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = 0.0, Maximum = maxPrecision, Title = "Recall"
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = 0.0, Maximum = 1.05, Title = "Precision"
            });
            model.Annotations.Add(max);

            plot.plot = model;
        }
Exemplo n.º 4
0
        static void GenerateGraph(ImagePlot plot)
        {
            
            PlotModel model = new PlotModel { Title = plot.name };
            
            model.LegendTitle = "Descriptor";
            if (arguments.Flip)
                model.LegendTitle = "Image";

            float maxPrecision = 0;
            int colorIndex = 0;

            foreach(DescriptorData data in plot.descriptors)
            {

                String title = data.descriptor;
                if (arguments.Flip)
                    title = data.image;

                title += " (" + data.correctMatches + "/" + data.totalMatches + ")";

                
                LineSeries line = new LineSeries { Title = title, Color = colors[colorIndex++ % colors.Length] };
                for (int i = 0; i < data.pointData.Count; i++ )
                {
                    maxPrecision = Math.Max(maxPrecision, data.pointData[i].precision);
                    line.Points.Add(new DataPoint(data.pointData[i].precision, data.pointData[i].recall));
                }
                model.Series.Add(line);
            }

            // If global scale is on, we'll use that instead.
            if (arguments.GlobalScale)
                maxPrecision = globalScaleMax;

            // Add some padding
            maxPrecision = (float)Math.Min(maxPrecision + (maxPrecision * .2), 1.2f);

            // If we aren't scaling, just set it to 1.0
            if (!arguments.Scale && !arguments.GlobalScale)
                maxPrecision = 1.0f;

            LineAnnotation max = new LineAnnotation { Type = LineAnnotationType.Vertical, X = 1.0, Color = OxyColors.LightGray, LineStyle = OxyPlot.LineStyle.Dash };

            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0.0, Maximum = maxPrecision, Title = "Recall" });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = 0.0, Maximum = 1.05, Title = "Precision" });
            model.Annotations.Add(max);

            plot.plot = model;

        }