public void TestSURFDetector2() { //Trace.WriteLine("Size of MCvSURFParams: " + Marshal.SizeOf(typeof(MCvSURFParams))); Image <Gray, byte> box = EmguAssert.LoadImage <Gray, byte>("box.png"); SURFDetector detector = new SURFDetector(400); Stopwatch watch = Stopwatch.StartNew(); VectorOfKeyPoint vp1 = new VectorOfKeyPoint(); Mat descriptors1 = new Mat(); detector.DetectAndCompute(box, null, vp1, descriptors1, false); watch.Stop(); EmguAssert.WriteLine(String.Format("Time used: {0} milliseconds.", watch.ElapsedMilliseconds)); watch.Reset(); watch.Start(); MKeyPoint[] keypoints = detector.Detect(box, null); //ImageFeature<float>[] features2 = detector.Compute(box, keypoints); watch.Stop(); EmguAssert.WriteLine(String.Format("Time used: {0} milliseconds.", watch.ElapsedMilliseconds)); watch.Reset(); watch.Start(); //MCvSURFParams p = detector.SURFParams; //SURFFeature[] features3 = box.ExtractSURF(ref p); //watch.Stop(); //EmguAssert.WriteLine(String.Format("Time used: {0} milliseconds.", watch.ElapsedMilliseconds)); // EmguAssert.IsTrue(features1.Length == features2.Length); //EmguAssert.IsTrue(features2.Length == features3.Length); PointF[] pts = #if NETFX_CORE Extensions. #else Array. #endif ConvertAll <MKeyPoint, PointF>(keypoints, delegate(MKeyPoint mkp) { return(mkp.Point); }); //SURFFeature[] features = box.ExtractSURF(pts, null, ref detector); //int count = features.Length; /* * for (int i = 0; i < features1.Length; i++) * { * Assert.AreEqual(features1[i].KeyPoint.Point, features2[i].KeyPoint.Point); * float[] d1 = features1[i].Descriptor; * float[] d2 = features2[i].Descriptor; * * for (int j = 0; j < d1.Length; j++) * Assert.AreEqual(d1[j], d2[j]); * }*/ foreach (MKeyPoint kp in keypoints) { box.Draw(new CircleF(kp.Point, kp.Size), new Gray(255), 1); } }