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;
}
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);
}
}
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);
}
}
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]);
}
}
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);
}
Aggregations