コード例 #1
0
ファイル: MainForm.cs プロジェクト: kamranamini61/Accord
        private void button1_Click(object sender, EventArgs e)
        {
            // Open a image
            Bitmap lenna = Surf.Properties.Resources.lena512;

            // Create a new SURF Features Detector using the given parameters
            SpeededUpRobustFeaturesDetector surf =
                new SpeededUpRobustFeaturesDetector(0.0002f, 5, 2);

            var points = surf.ProcessImage(lenna);

            // Get the SURF Features Descriptor from the detector
            SurfDescriptor descriptor = surf.GetDescriptor();

            descriptor.Describe(points);

            // Create a new AForge's Corner Marker Filter
            FeaturesMarker features = new FeaturesMarker(points.ToArray());

            // Apply the filter and display it on a picturebox
            pictureBox1.Image = features.Apply(lenna);
        }
コード例 #2
0
        public void ProcessImageTest()
        {
            // Load an Image
            Bitmap img = Properties.Resources.sample_trans;

            // Extract the interest points
            var surf = new SpeededUpRobustFeaturesDetector(0.0002f, 5, 2);
            List <SurfPoint> points = surf.ProcessImage(img);

            // Describe the interest points
            SurfDescriptor descriptor = surf.GetDescriptor();

            descriptor.Describe(points);

            Assert.AreEqual(8, points.Count);

            SurfPoint p;

            p = points[0];
            Assert.AreEqual(0, p.Laplacian);
            Assert.AreEqual(25.3803387, p.X, 1e-2);
            Assert.AreEqual(14.7987738, p.Y, 1e-2);
            Assert.AreEqual(1.98713827, p.Scale, 1e-2);
            Assert.AreEqual(0.0, p.Response, 1e-2);
            Assert.AreEqual(4.78528404, p.Orientation, 1e-2);
            Assert.AreEqual(64, p.Descriptor.Length);
            Assert.AreEqual(0.22572951, p.Descriptor[23], 1e-2);
            Assert.AreEqual(0.0962982625, points[1].Descriptor[42], 1e-2);

            p = points[1];
            Assert.AreEqual(1, p.Laplacian, 1e-2);
            Assert.AreEqual(20.4856224, p.X, 1e-2);
            Assert.AreEqual(20.4817181, p.Y, 1e-2);
            Assert.AreEqual(1.90549147, p.Scale, 1e-2);
            Assert.AreEqual(0.0, p.Response, 1e-2);
            Assert.AreEqual(4.89748764, p.Orientation, 1e-2);
            Assert.AreEqual(64, p.Descriptor.Length);
            Assert.AreEqual(0.14823015, p.Descriptor[23], 1e-2);
            Assert.AreEqual(0.0861000642, p.Descriptor[54], 1e-2);

            p = points[2];
            Assert.AreEqual(0, p.Laplacian, 1e-2);
            Assert.AreEqual(14.7991896, p.X, 1e-2);
            Assert.AreEqual(25.3776169, p.Y, 1e-2);
            Assert.AreEqual(1.9869982, p.Scale, 1e-2);
            Assert.AreEqual(0.0, p.Response, 1e-2);
            Assert.AreEqual(3.07735944, p.Orientation, 1e-2);
            Assert.AreEqual(64, p.Descriptor.Length);
            Assert.AreEqual(0.209485427, p.Descriptor[23], 1e-2);
            Assert.AreEqual(0.0112418151, p.Descriptor[12], 1e-2);

            p = points[6];
            Assert.AreEqual(1, p.Laplacian, 1e-2);
            Assert.AreEqual(22.4346638, p.X, 1e-2);
            Assert.AreEqual(41.4026527, p.Y, 1e-2);
            Assert.AreEqual(2.83586049, p.Scale, 1e-2);
            Assert.AreEqual(0.0, p.Response, 1e-2);
            Assert.AreEqual(3.13142157, p.Orientation, 1e-2);
            Assert.AreEqual(64, p.Descriptor.Length);
            Assert.AreEqual(0.0467314087, p.Descriptor[23], 1e-2);
            Assert.AreEqual(0.0266618263, p.Descriptor[12], 1e-2);


            descriptor.Extended  = true;
            descriptor.Invariant = false;
            descriptor.Describe(points);

            p = points[5];
            Assert.AreEqual(1, p.Laplacian, 1e-3);
            Assert.AreEqual(41.4027748, p.X, 1e-3);
            Assert.AreEqual(22.4343891, p.Y, 1e-3);
            Assert.AreEqual(2.83486962, p.Scale, 1e-3);
            Assert.AreEqual(0.0, p.Response, 1e-3);
            Assert.AreEqual(4.72728586, p.Orientation, 1e-3);
            Assert.AreEqual(0.00786296651, p.Descriptor[67], 1e-3);
            Assert.AreEqual(-0.0202884115, p.Descriptor[97], 1e-2);
        }