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