Search in sources :

Example 11 with BrightFeature

use of boofcv.struct.feature.BrightFeature in project BoofCV by lessthanoptimal.

the class TestDescribePointSurfPlanar method compareToSingleBand.

/**
 * Computes the descriptor inside a random image.  Sees if it has the expected results by comparing it to
 * the single band algorithm which it uses internally.
 */
@Test
public void compareToSingleBand() {
    Planar<GrayF32> input = new Planar<>(GrayF32.class, width, height, 3);
    GImageMiscOps.addUniform(input, rand, 0, 200);
    DescribePointSurf<GrayF32> desc = new DescribePointSurf<>(GrayF32.class);
    DescribePointSurfPlanar<GrayF32> alg = new DescribePointSurfPlanar<>(desc, 3);
    GrayF32 gray = ConvertImage.average(input, null);
    // input isn't an integral image, but I just want to see if it produces the expected results
    alg.setImage(gray, input);
    for (int i = 0; i < 100; i++) {
        double x = rand.nextDouble() * width;
        double y = rand.nextDouble() * height;
        double angle = rand.nextDouble() * Math.PI * 2;
        double scale = rand.nextDouble() * 10 + 0.9;
        BrightFeature found = alg.createDescription();
        alg.describe(x, y, angle, scale, found);
        desc.setImage(gray);
        boolean expectedLaplace = desc.computeLaplaceSign((int) (x + 0.5), (int) (y + 0.5), scale);
        assertEquals(expectedLaplace, found.white);
        BrightFeature expected = desc.createDescription();
        for (int b = 0; b < 3; b++) {
            desc.setImage(input.getBand(b));
            desc.describe(x, y, angle, scale, expected);
            // should be off by a constant scale factor since it is normalized across all bands not just one
            double norm = 0;
            for (int j = 0; j < expected.size(); j++) {
                double v = found.getDouble(j + b * expected.size());
                norm += v * v;
            }
            norm = Math.sqrt(norm);
            for (int j = 0; j < expected.size(); j++) {
                assertEquals(expected.getDouble(j), found.getDouble(j + b * expected.size()) / norm, 1e-8);
            }
        }
    }
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Test(org.junit.Test)

Example 12 with BrightFeature

use of boofcv.struct.feature.BrightFeature in project BoofCV by lessthanoptimal.

the class TestAssociateSurfBasic method basicAssociation.

@Test
public void basicAssociation() {
    FastQueue<BrightFeature> src = new FastQueue<>(10, BrightFeature.class, false);
    FastQueue<BrightFeature> dst = new FastQueue<>(10, BrightFeature.class, false);
    // create a list where some should be matched and others not
    src.add(createDesc(true, 10));
    src.add(createDesc(true, 12));
    src.add(createDesc(false, 5));
    src.add(createDesc(false, 2344));
    src.add(createDesc(false, 1000));
    dst.add(createDesc(true, 0));
    dst.add(createDesc(true, 10.1));
    dst.add(createDesc(true, 13));
    dst.add(createDesc(false, 0.1));
    dst.add(createDesc(false, 7));
    alg.setSrc(src);
    alg.setDst(dst);
    alg.associate();
    FastQueue<AssociatedIndex> matches = alg.getMatches();
    assertEquals(3, matches.size());
    assertTrue(matches.get(0).fitScore != 0);
    assertEquals(0, matches.get(0).src);
    assertEquals(1, matches.get(0).dst);
    assertTrue(matches.get(1).fitScore != 0);
    assertEquals(1, matches.get(1).src);
    assertEquals(2, matches.get(1).dst);
    assertTrue(matches.get(2).fitScore != 0);
    assertEquals(2, matches.get(2).src);
    assertEquals(4, matches.get(2).dst);
    // see if the expected number of features are in the unassociated list
    GrowQueue_I32 unassoc = alg.unassociatedSrc;
    assertEquals(2, unassoc.size);
    // make sure none of the unassociated are contained in the associated list
    for (int i = 0; i < unassoc.size; i++) {
        int index = unassoc.data[i];
        for (int j = 0; j < matches.size(); j++) {
            if (matches.get(j).src == index)
                fail("match found");
        }
    }
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) FastQueue(org.ddogleg.struct.FastQueue) AssociatedIndex(boofcv.struct.feature.AssociatedIndex) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 13 with BrightFeature

use of boofcv.struct.feature.BrightFeature in project narchy by automenta.

the class ExampleStereoTwoViewsOneCamera method computeMatches.

/**
 * Use the associate point feature example to create a list of {@link AssociatedPair} for use in computing the
 * fundamental matrix.
 */
public void computeMatches(GrayF32 left, GrayF32 right) {
    DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(1, 2, 0, 1, 9, 4, 4), null, null, GrayF32.class);
    // DetectDescribePoint detDesc = FactoryDetectDescribe.sift(null,new ConfigSiftDetector(2,0,200,5),null,null);
    ScoreAssociation<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class, true);
    AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer, 0.9, true);
    ExampleAssociatePoints<GrayF32, BrightFeature> findMatches = new ExampleAssociatePoints<>(detDesc, associate, GrayF32.class);
    findMatches.associate(left, right);
    FastQueue<AssociatedIndex> matchIndexes = associate.getMatches();
    matchedFeatures.clear();
    for (int i = 0; i < matchIndexes.size; i++) {
        AssociatedIndex a = matchIndexes.get(i);
        matchedFeatures.add(new AssociatedPair(findMatches.pointsA.get(a.src), findMatches.pointsB.get(a.dst)));
    }
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedPair(boofcv.struct.geo.AssociatedPair) BrightFeature(boofcv.struct.feature.BrightFeature) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 14 with BrightFeature

use of boofcv.struct.feature.BrightFeature in project BoofCV by lessthanoptimal.

the class BaseTestDescribeSurf method changeScale.

/**
 * Does it produce a different feature when scalled?
 */
@Test
public void changeScale() {
    GImageMiscOps.fillUniform(ii, rand, 0, 100);
    alg.setImage(ii);
    BrightFeature a = alg.createDescription();
    BrightFeature b = alg.createDescription();
    alg.describe(c_x, c_y, 0, 1, a);
    alg.describe(c_x, c_y, 0, 1.5, b);
    assertFalse(isSimilar(a, b));
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) Test(org.junit.Test)

Example 15 with BrightFeature

use of boofcv.struct.feature.BrightFeature in project BoofCV by lessthanoptimal.

the class BaseTestDescribeSurf method features_increasing.

/**
 * Create an image which has a constant slope.  The features aligned along that
 * direction should be large.  This also checks that the orientation parameter
 * is being used correctly and that absolute value is being done.
 */
@Test
public void features_increasing() {
    // test the gradient along the x-axis only
    TestImplSurfDescribeOps.createGradient(0, input);
    GIntegralImageOps.transform(input, ii);
    sparse = TestImplSurfDescribeOps.createGradient(ii, 1);
    // orient the feature along the x-axis
    alg.setImage(ii);
    BrightFeature feat = alg.createDescription();
    alg.describe(15, 15, 0, 1, feat);
    for (int i = 0; i < 64; i += 4) {
        assertEquals(feat.value[i], feat.value[i + 1], 1e-4);
        assertTrue(feat.value[i] > 0);
        assertEquals(0, feat.value[i + 2], 1e-4);
        assertEquals(0, feat.value[i + 3], 1e-4);
    }
    // now orient the feature along the y-axis
    alg.describe(15, 15, Math.PI / 2.0, 1, feat);
    for (int i = 0; i < 64; i += 4) {
        assertEquals(-feat.value[i + 2], feat.value[i + 3], 1e-4);
        assertTrue(feat.value[i + 2] < 0);
        assertEquals(0, feat.value[i], 1e-4);
        assertEquals(0, feat.value[i + 1], 1e-4);
    }
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) Test(org.junit.Test)

Aggregations

BrightFeature (boofcv.struct.feature.BrightFeature)22 Test (org.junit.Test)11 GrayF32 (boofcv.struct.image.GrayF32)6 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)4 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)4 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)3 ScalePoint (boofcv.struct.feature.ScalePoint)3 AssociatedPair (boofcv.struct.geo.AssociatedPair)3 OrientationImage (boofcv.abst.feature.orientation.OrientationImage)2 ArrayList (java.util.ArrayList)2 FastQueue (org.ddogleg.struct.FastQueue)2 GrowQueue_F64 (org.ddogleg.struct.GrowQueue_F64)2 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)2 ConfigExtract (boofcv.abst.feature.detect.extract.ConfigExtract)1 NonMaxSuppression (boofcv.abst.feature.detect.extract.NonMaxSuppression)1 FastHessianFeatureDetector (boofcv.alg.feature.detect.interest.FastHessianFeatureDetector)1 ExampleAssociatePoints (boofcv.examples.features.ExampleAssociatePoints)1 ConfigRansac (boofcv.factory.geo.ConfigRansac)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 SurfFeatureQueue (boofcv.struct.feature.SurfFeatureQueue)1