Search in sources :

Example 1 with TupleDesc_B

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

the class TestDdaManagerGeneralPoint method createTracker.

@Override
public PointTracker<GrayF32> createTracker() {
    DescribePointBrief<GrayF32> brief = FactoryDescribePointAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512), FactoryBlurFilter.gaussian(ImageType.single(GrayF32.class), 0, 4));
    GeneralFeatureDetector<GrayF32, GrayF32> corner = FactoryDetectPoint.createShiTomasi(new ConfigGeneralDetector(-1, 2, 0), false, GrayF32.class);
    ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
    AssociateDescription2D<TupleDesc_B> association = new AssociateDescTo2D<>(FactoryAssociation.greedy(score, 400, true));
    DescribeRegionPoint<GrayF32, TupleDesc_B> describe = new WrapDescribeBrief<>(brief, GrayF32.class);
    EasyGeneralFeatureDetector<GrayF32, GrayF32> easy = new EasyGeneralFeatureDetector<>(corner, GrayF32.class, GrayF32.class);
    DdaManagerGeneralPoint<GrayF32, GrayF32, TupleDesc_B> manager;
    manager = new DdaManagerGeneralPoint<>(easy, describe, 2);
    DetectDescribeAssociate<GrayF32, TupleDesc_B> tracker = new DetectDescribeAssociate<>(manager, association, false);
    return tracker;
}
Also used : ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) AssociateDescTo2D(boofcv.abst.feature.associate.AssociateDescTo2D) ScoreAssociateHamming_B(boofcv.abst.feature.associate.ScoreAssociateHamming_B) WrapDescribeBrief(boofcv.abst.feature.describe.WrapDescribeBrief) TupleDesc_B(boofcv.struct.feature.TupleDesc_B) GrayF32(boofcv.struct.image.GrayF32) Random(java.util.Random) EasyGeneralFeatureDetector(boofcv.alg.feature.detect.interest.EasyGeneralFeatureDetector)

Example 2 with TupleDesc_B

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

the class TestScoreAssociateHamming_B method testRandom.

/**
 * Generate random descriptions and see two hamming distance calculations return the same result.
 */
@Test
void testRandom() {
    ScoreAssociateHamming_B scorer = new ScoreAssociateHamming_B();
    TupleDesc_B a = new TupleDesc_B(512);
    TupleDesc_B b = new TupleDesc_B(512);
    for (int numTries = 0; numTries < 20; numTries++) {
        for (int i = 0; i < a.data.length; i++) {
            a.data[i] = rand.nextInt();
            b.data[i] = rand.nextInt();
        }
        int expected = DescriptorDistance.hamming(a, b);
        assertEquals(expected, scorer.score(a, b), 1e-4);
    }
}
Also used : TupleDesc_B(boofcv.struct.feature.TupleDesc_B) Test(org.junit.jupiter.api.Test)

Example 3 with TupleDesc_B

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

the class BenchmarkDescribe method Brief512.

@Benchmark
public void Brief512() {
    DescribePointBrief<I> alg = FactoryDescribeAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512), FactoryBlurFilter.gaussian(imageType, 0, 4));
    alg.setImage(gray);
    TupleDesc_B f = alg.createFeature();
    for (int i = 0; i < pts.length; i++) {
        Point2D_I32 p = pts[i];
        alg.process(p.x, p.y, f);
    }
}
Also used : TupleDesc_B(boofcv.struct.feature.TupleDesc_B) Random(java.util.Random) Point2D_I32(georegression.struct.point.Point2D_I32)

Example 4 with TupleDesc_B

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

the class BaseTestDescribePointBinaryCompare method testSubImage.

/**
 * Have brief process a sub-image and see if it produces the same results.
 */
@Test
void testSubImage() {
    T input = createImage(width, height);
    DescribePointBinaryCompare<T> alg = createAlg(def);
    TupleDesc_B desc1 = createFeature();
    TupleDesc_B desc2 = createFeature();
    // resize the image and see if it computes the same output
    alg.setImage(input);
    alg.process(input.width / 2, input.height / 2, desc1);
    T sub = (T) BoofTesting.createSubImageOf(input);
    alg.setImage(sub);
    alg.process(input.width / 2, input.height / 2, desc2);
    for (int i = 0; i < desc1.data.length; i++) {
        assertEquals(desc1.data[i], desc2.data[i]);
    }
}
Also used : TupleDesc_B(boofcv.struct.feature.TupleDesc_B) Test(org.junit.jupiter.api.Test)

Example 5 with TupleDesc_B

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

the class BaseTestDescribePointBinaryCompare method testIntensityInvariance.

/**
 * Vary the intensity of the input image and see if the description changes.
 */
@Test
void testIntensityInvariance() {
    T input = createImage(width, height);
    T mod = (T) input.clone();
    GPixelMath.multiply(input, 2, mod);
    DescribePointBinaryCompare<T> alg = createAlg(def);
    TupleDesc_B desc1 = createFeature();
    TupleDesc_B desc2 = createFeature();
    // compute the image from the same image but different intensities
    alg.setImage(input);
    alg.process(input.width / 2, input.height / 2, desc1);
    alg.setImage(mod);
    alg.process(input.width / 2, input.height / 2, desc2);
    // compare the descriptions
    int count = 0;
    for (int i = 0; i < desc1.numBits; i++) {
        count += desc1.isBitTrue(i) == desc2.isBitTrue(i) ? 1 : 0;
    }
    // blurring the image can cause some bits to switch in the description
    assertTrue(count > desc1.numBits - 3);
}
Also used : TupleDesc_B(boofcv.struct.feature.TupleDesc_B) Test(org.junit.jupiter.api.Test)

Aggregations

TupleDesc_B (boofcv.struct.feature.TupleDesc_B)24 Test (org.junit.jupiter.api.Test)14 GrayF32 (boofcv.struct.image.GrayF32)11 Random (java.util.Random)6 ScoreAssociateHamming_B (boofcv.abst.feature.associate.ScoreAssociateHamming_B)4 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)4 Point2D_I32 (georegression.struct.point.Point2D_I32)4 AssociateDescTo2D (boofcv.abst.feature.associate.AssociateDescTo2D)2 WrapDescribeBrief (boofcv.abst.feature.describe.WrapDescribeBrief)2 EasyGeneralFeatureDetector (boofcv.alg.feature.detect.interest.EasyGeneralFeatureDetector)2 DogArray_I32 (org.ddogleg.struct.DogArray_I32)2 DetectDescribeFusion (boofcv.abst.feature.detdesc.DetectDescribeFusion)1 AssociateMaxDistanceNaive (boofcv.alg.feature.associate.AssociateMaxDistanceNaive)1 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)1 GImageGray (boofcv.core.image.GImageGray)1 ArrayList (java.util.ArrayList)1 ListAccessor (org.ddogleg.clustering.misc.ListAccessor)1 DogArray (org.ddogleg.struct.DogArray)1