static void Main() { long noOfPaths = MyAlgorithms.CountPaths(21, 21); Console.WriteLine(noOfPaths); Console.ReadKey(); }
public void Linear_Exception() { double a = -5; double c = 3; double delta = 0.07; double actual = MyAlgorithms.Linear(a, c); }
public void CycleTest() { double[] mas = new double[] { 2, 3, 4, 5, 6, 7 }; double expect = 30379; double actual = MyAlgorithms.Cyclic(mas); Assert.AreEqual(expect, actual); }
public void Linear_5and3_12returned() { double a = 5; double c = 3; double delta = 0.07; double expected = 12.2857142; double actual = MyAlgorithms.Linear(a, c); Assert.AreEqual(expected, actual, delta); }
private void Test() { var SourceImage = new Image <Bgr, byte>(@"C:\Temp\bc2.jpg"); MyAlgorithms myA = new MyAlgorithms(SourceImage); Image <Gray, byte> imageGray = myA.MakeGray(); //pictureBox1.Image = SourceImage.ToBitmap(); pbSourceImage.Image = SourceImage.ToBitmap(); pbPrcessedImageStep1.Image = myA.Pixelize(myA.Contours(imageGray)).ToBitmap(); }
public void Branched_1_2_3_4() { double x = 1; double b = 2; double c = 3; double k = 4; double expect = 9; double actual = MyAlgorithms.Branched(x, b, c, k); Assert.AreEqual(expect, actual); }
public void RunFeature(string featureName) { switch (featureName) { case "Feature1": MyAlgorithms.AccessFeature1(); break; case "Feature2": MyAlgorithms.AccessFeature2(); break; case "Feature3": MyAlgorithms.AccessFeature3(); break; default: throw new ArgumentOutOfRangeException("featureName"); } LastSuccessfulFeatureExecutionMessage = string.Format("{0} accessed successfully", featureName); }
static void RunTest(int arrayLength) { var processTimes = new List <TimeSpan>(); var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < 5; i++) { var arr = MyAlgorithms.CreateRandomDoubleArray(arrayLength, 0, 200); MyAlgorithms.GetMax(arr); processTimes.Add(sw.Elapsed); sw.Restart(); } sw.Stop(); GC.Collect(); GC.WaitForPendingFinalizers(); Console.WriteLine(processTimes.Average(x => x.TotalSeconds) + " - " + arrayLength); }
void RunFeature2_Click(object sender, RoutedEventArgs e) { MyAlgorithms.AccessFeature2(); NotifyUser("Feature 2 accessed successfully"); }
private void btnTest_Click(object sender, EventArgs e) { //tbImageName.Text = @"\IKEA\20201107_190718.jpg"; //string imagePath = @"C:\Temp\" + tbImageName.Text; //string imagePath = @"C:\temp\IKEA\sim.png"; //ip.SetImage(imagePath); //var img = new Image<Bgr, byte>(@"C:\Temp\IKEA\sim.png"); var img1 = new Image <Bgr, byte>(@"C:\Temp\IKEA\20201107_190718.jpg"); var img = new MyAlgorithms().Contours(img1.Convert <Gray, byte>()); //img.ToBitmap().Save(@"C:\Temp\IKEA\Shape__.png", ImageFormat.Png); var shape = new Image <Bgr, byte>(@"C:\temp\IKEA\shape_2.png"); VectorOfVectorOfDMatch matches = new VectorOfVectorOfDMatch(); Mat res = new Mat(); CvInvoke.MatchTemplate(img, shape, res, TemplateMatchingType.CcoeffNormed); var img2 = res.ToImage <Gray, byte>(); var data = res.GetData(); double[] max = new double[3] { 0, 0, 0 }; for (int r = 0; r < res.Rows; r += 1) { for (int c = 0; c < res.Cols; c += 1) { if (Convert.ToDouble(data.GetValue(r, c)) > max[2]) { max[0] = r; max[1] = c; max[2] = Convert.ToDouble(data.GetValue(r, c)); } } } ip.DrawGreenFrame(img.Mat, new Rectangle(new Point((int)max[1], (int)max[0]), new Size(shape.Width, shape.Height)), 1); //MyAlgorithms.FindMatch(shape.Mat, ip.SourceImage.Mat, out long matchTime, out VectorOfKeyPoint modelKeyPoints, out VectorOfKeyPoint observedKeyPoints, matches, out Mat mask, out Mat homography); //List<MDMatch[]> good = new List<MDMatch[]>(); //List<MKeyPoint> points1 = new List<MKeyPoint>(); //int idx = 0; //foreach (MDMatch[] m in matches.ToArrayOfArray()) //{ // if (m[0].Distance < 0.85 * m[1].Distance) // { // good.Add(m); // points1.Add(observedKeyPoints[idx]); // } // idx++; //} //foreach (MKeyPoint p in points1) //{ // ip.DrawGreenFrame(ip.SourceImage.Mat, new Rectangle(new Point((int)p.Point.X, (int)p.Point.Y), new Size(shape.Width, shape.Height)), 1); // ip.DrawGreenFrame(ip.SourceImage.Mat, new Rectangle(new Point((int)p.Point.X, (int)p.Point.Y), new Size(shape.Width, shape.Height)), 1); //} DisplayImg(pbSourceImage, img.Mat); DisplayImg(pbFinalPreviewImage, img.Mat); }