Example #1
0
        public static void RunExperiment(string name, string folder, string prefix, string outputDirectory = "")
        {
            if (outputDirectory == String.Empty)
            {
                outputDirectory = Path.Combine(Drive.GetDriveRoot(), BenchmarkDirectory);
                //Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            }

            var drive      = new Drive(folder, Drive.Reason.Read);
            var experiment = new Experiment(drive.Files(prefix).ToList(), UseOcr);
            var mixed      = experiment.MixedOrder;
            var normal     = experiment.CorrectOrder;
            var results    = Reconstructor.NaiveKruskalAlgorithm(mixed);
            var difference = experiment.Diff(results);

            var resultImg = Path.Combine(outputDirectory, name + "_result.png");

            Stitcher.ExportImage((Cluster)results.First().Root(), resultImg);

            var sb = new StringBuilder();

            sb.AppendLine(name);
            sb.AppendLine(folder);
            sb.AppendLine(difference.ToString());
            mixed.ForEach(shred => sb.Append(" " + shred.Id + ", "));
            sb.AppendLine();
            normal.ForEach(shred => sb.Append(" " + shred.Id + ", "));
            sb.AppendLine();
            results.ForEach(shred => sb.Append(" " + shred.Id + ", "));
            sb.AppendLine();

            Console.WriteLine(sb.ToString());
            File.WriteAllText(Path.Combine(outputDirectory, name + ".txt"), sb.ToString());
        }
 public static void ExportResult(Cluster root, string imageName = "out.png", string path = @"../../visualizer/data.js")
 {
     try
     {
         Exporter.ExportJson(root, path);
     }
     catch (Exception ee)
     {
         Console.WriteLine("JSON Export Failed");
         Console.WriteLine(ee.ToString());
     }
     try
     {
         Stitcher.ExportImage(root, imageName);
     }
     catch (Exception ee)
     {
         Console.WriteLine("Image Export Failed");
         Console.WriteLine(ee.ToString());
     }
 }