static void CircleTest(string path) { Console.WriteLine("======= CIRCLE TEST ======="); Progress <String> progress = new Progress <string>(pr => Console.WriteLine(pr)); //Mat mat = CvInvoke.Imread(path, ImreadModes.AnyColor); CircleParameters p = new CircleParameters(Path.GetFullPath("tests/Circle.DObject"), path, 150, "colors.DColor", ColorDetectionMode.CieDe2000Comparison, new FloydSteinbergDithering(), AverageMode.Corner, new NoColorRestriction()); p.AngleShiftFactor = -0.02; p.ForceDivisibility = 5; p.StartDiameter = 200; ((NonEmptyCalculation)p.PrimaryCalculation).Dithering = new FloydSteinbergDithering(); var watch = System.Diagnostics.Stopwatch.StartNew(); //DominoTransfer t = await Dispatcher.CurrentDispatcher.Invoke(async () => await Task.Run(() => p.Generate(wb, progress))); DominoTransfer t = p.Generate(); Console.WriteLine(t.length); watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); watch = System.Diagnostics.Stopwatch.StartNew(); Mat b2 = t.GenerateImage(); watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); b2.Save("tests/CircleTest.png"); FileStream fs = new FileStream(@"SpiralPlanTest.html", FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.Write(p.GetHTMLProcotol(new ObjectProtocolParameters() { backColorMode = ColorMode.Normal, foreColorMode = ColorMode.Intelligent, orientation = Core.Orientation.Horizontal, //reverse = false, summaryMode = SummaryMode.Large, textFormat = "<font face=\"Verdana\">", templateLength = 20, textRegex = "%count% %color%", title = "Field" })); //p.SaveXLSFieldPlan("ExcelFieldPlanTest.xlsx", new ObjectProtocolParameters() //{ // backColorMode = ColorMode.Normal, // foreColorMode = ColorMode.Intelligent, // orientation = Orientation.Horizontal, // reverse = false, // summaryMode = SummaryMode.Large, // textFormat = "<font face=\"Verdana\">", // templateLength = 20, // textRegex = "%count%", // title = "Field", // path = Directory.GetCurrentDirectory() //}); sw.Close(); p.Save(); IDominoProvider c = Workspace.Load <IDominoProvider>("circle.DObject"); }
static void SpiralTest(string path) { Console.WriteLine("======= SPIRAL TEST ======="); Progress <String> progress = new Progress <string>(pr => Console.WriteLine(pr)); //Mat mat = CvInvoke.Imread(path, ImreadModes.AnyColor); SpiralParameters p = new SpiralParameters(Path.GetFullPath("tests/Spiral.DObject"), path, 50, "colors.DColor", ColorDetectionMode.CieDe2000Comparison, new Dithering(), AverageMode.Corner, new NoColorRestriction()); p.ThetaMin = 0.3d * Math.PI; var watch = System.Diagnostics.Stopwatch.StartNew(); //DominoTransfer t = await Dispatcher.CurrentDispatcher.Invoke(async () => await Task.Run(() => p.Generate(wb, progress))); DominoTransfer t = p.Generate(); Console.WriteLine(t.length); watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); watch = System.Diagnostics.Stopwatch.StartNew(); Mat b2 = t.GenerateImage(Colors.Transparent); watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); b2.Save("tests/SpiralTest.png"); FileStream fs = new FileStream(@"SpiralPlanTest.html", FileMode.Create); StreamWriter sw = new StreamWriter(fs); /*sw.Write(p.GetHTMLProcotol(new ObjectProtocolParameters() * { * backColorMode = ColorMode.Normal, * foreColorMode = ColorMode.Intelligent, * orientation = Core.Orientation.Horizontal, * reverse = false, * summaryMode = SummaryMode.Large, * textFormat = "<font face=\"Verdana\">", * templateLength = 20, * textRegex = "%count% %color%", * title = "Field" * }));*/ //p.SaveXLSFieldPlan("ExcelFieldPlanTest.xlsx", new ObjectProtocolParameters() //{ // backColorMode = ColorMode.Normal, // foreColorMode = ColorMode.Intelligent, // orientation = Orientation.Horizontal, // reverse = false, // summaryMode = SummaryMode.Large, // textFormat = "<font face=\"Verdana\">", // templateLength = 20, // textRegex = "%count%", // title = "Field", // path = Directory.GetCurrentDirectory() //}); sw.Close(); p.Save(); watch = Stopwatch.StartNew(); int[] counts = Workspace.LoadColorList <SpiralParameters>(Path.GetFullPath("tests/Spiral.DObject")).Item2; watch.Stop(); Console.WriteLine("Preview Load Time: " + watch.ElapsedMilliseconds); Console.WriteLine(String.Join(", ", counts)); Workspace.Clear(); watch = Stopwatch.StartNew(); SpiralParameters loaded = Workspace.Load <SpiralParameters>(Path.GetFullPath("tests/Spiral.DObject")); loaded.Generate().GenerateImage().Save("tests/spiral_after_load.png"); }