Exemplo n.º 1
0
        public void ProcessImageTest4()
        {
            var bitmaps = GetImages();
            var surf    = new SpeededUpRobustFeaturesDetector();

            int current = 0;

            foreach (Bitmap img in bitmaps)
            {
                List <SpeededUpRobustFeaturePoint> expected;
                List <SpeededUpRobustFeaturePoint> actual;

                // Create OpenSURF detector by Chris Evans
                {
                    // Create Integral Image
                    OpenSURFcs.IntegralImage iimg = OpenSURFcs.IntegralImage.FromImage(img);

                    // Extract the interest points
                    var pts = OpenSURFcs.FastHessian.getIpoints(0.0002f, 5, 2, iimg);

                    // Describe the interest points
                    OpenSURFcs.SurfDescriptor.DecribeInterestPoints(pts, false, false, iimg);

                    expected = new List <SpeededUpRobustFeaturePoint>();
                    foreach (var p in pts)
                    {
                        expected.Add(new SpeededUpRobustFeaturePoint(p.x, p.y, p.scale,
                                                                     p.laplacian, p.orientation, p.response));
                    }
                }

                // Create Accord.NET SURF detector (based on OpenSURF by Chris Evans)
                {
                    actual = surf.ProcessImage(img);
                }

                var img1 = new FeaturesMarker(actual).Apply(img);
                var img2 = new FeaturesMarker(expected).Apply(img);

                // ImageBox.Show(new Concatenate(img1).Apply(img2), PictureBoxSizeMode.Zoom);


                current++;

                for (int i = 0; i < expected.Count; i++)
                {
                    SpeededUpRobustFeaturePoint e = expected[i];
                    SpeededUpRobustFeaturePoint a = actual[i];
                    Assert.AreEqual(e, a);
                }
            }
        }
        public void ProcessImageTest()
        {
            Bitmap[] bitmaps =
            {
                Resources.flower01,
                Resources.flower03,
                Resources.flower06,
                Resources.flower07,
                Resources.flower09,
                Resources.flower10,
            };

            foreach (Bitmap img in bitmaps)
            {
                bool upright  = true;
                bool extended = false;

                List <SpeededUpRobustFeaturePoint> expected;
                List <SpeededUpRobustFeaturePoint> actual;

                // Create OpenSURF detector by Chris Evans
                {
                    // Create Integral Image
                    OpenSURFcs.IntegralImage iimg = OpenSURFcs.IntegralImage.FromImage(img);

                    // Extract the interest points
                    var pts = OpenSURFcs.FastHessian.getIpoints(0.0002f, 5, 2, iimg);

                    // Describe the interest points
                    OpenSURFcs.SurfDescriptor.DecribeInterestPoints(pts, upright, extended, iimg);

                    expected = new List <SpeededUpRobustFeaturePoint>();
                    foreach (var p in pts)
                    {
                        expected.Add(new SpeededUpRobustFeaturePoint(
                                         p.x, p.y, p.scale,
                                         p.laplacian, p.orientation,
                                         p.response, p.descriptor.ToDouble()));
                    }
                }

                // Create the detector
                var surf = new SpeededUpRobustFeaturesDetector(0.0002f, 5, 2);

                // Extract interest points
                actual = surf.ProcessImage(img);

                // Describe the interest points
                var descriptor = surf.GetDescriptor();
                descriptor.Invariant = !upright;
                descriptor.Extended  = extended;

                foreach (var expectedPoint in expected)
                {
                    var actualPoint = new SpeededUpRobustFeaturePoint(
                        expectedPoint.X,
                        expectedPoint.Y,
                        expectedPoint.Scale,
                        expectedPoint.Laplacian);

                    descriptor.Compute(actualPoint);

                    Assert.AreEqual(expectedPoint.X, actualPoint.X);
                    Assert.AreEqual(expectedPoint.Y, actualPoint.Y);
                    Assert.AreEqual(expectedPoint.Scale, actualPoint.Scale);
                    Assert.AreEqual(expectedPoint.Orientation, actualPoint.Orientation);
                    Assert.AreEqual(expectedPoint.Response, actualPoint.Response);
                    Assert.AreEqual(expectedPoint.Descriptor.Length, actualPoint.Descriptor.Length);

                    for (int i = 0; i < expectedPoint.Descriptor.Length; i++)
                    {
                        double e = expectedPoint.Descriptor[i];
                        double a = actualPoint.Descriptor[i];

                        double u = System.Math.Abs(e - a);
                        double v = System.Math.Abs(e);
                        Assert.AreEqual(e, a, 0.05);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public SURFFeature(SpeededUpRobustFeaturePoint AccordSURFFeaturePoint, string TagSet) : base(AccordSURFFeaturePoint.Descriptor, TagSet)
 {
     Original = AccordSURFFeaturePoint;
 }
Exemplo n.º 4
0
 public SURFFeature() : base(new float[Length], null)
 {
     Original = new SpeededUpRobustFeaturePoint(-1, -1, -1, -1, -1, -1, null);
 }