use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.
the class CompareConvertedDescriptionsApp method describeImage.
public static <TD extends TupleDesc<TD>> FastArray<TD> describeImage(GrayF32 input, InterestPointDetector<GrayF32> detector, DescribePointRadiusAngle<GrayF32, TD> describe, List<Point2D_F64> location) {
FastArray<TD> list = new FastArray<>(describe.getDescriptionType());
System.out.println("Detecting");
detector.detect(input);
System.out.println("Describing");
describe.setImage(input);
for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
Point2D_F64 p = detector.getLocation(i);
double radius = detector.getRadius(i);
double ori = detector.getOrientation(i);
TD d = describe.createDescription();
if (describe.process(p.x, p.y, ori, radius, d)) {
list.add(d);
location.add(p.copy());
}
}
return list;
}
use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.
the class TestFeatureSelectNBest method tooFewFeatures.
/**
* The size of N is less than the number of points
*/
@Test
void tooFewFeatures() {
GrayF32 intensity = new GrayF32(10, 20);
intensity.set(5, 10, -3);
intensity.set(4, 10, -3.5f);
intensity.set(5, 11, 0);
intensity.set(8, 8, 10);
QueueCorner detected = new QueueCorner();
detected.append(5, 10);
detected.append(4, 10);
detected.append(5, 11);
detected.append(8, 8);
var found = new FastArray<>(Point2D_I16.class);
FeatureSelectNBest<Point2D_I16> alg = new FeatureSelectNBest<>(new SampleIntensityImage.I16());
alg.select(intensity, -1, -1, true, null, detected, 20, found);
assertEquals(4, found.size);
}
use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.
the class TestFeatureSelectUniform method checkAllCells.
/**
* Makes sure it found features in all cells
*/
@Test
void checkAllCells() {
// every pixel is a corner
QueueCorner detected = new QueueCorner();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
detected.grow().setTo(x, y);
}
}
int cellSize = 10;
var found = new FastArray<>(Point2D_I16.class);
FeatureSelectUniform<Point2D_I16> alg = createAlgorithm();
// make it easy to know the cell size
alg.configUniform = new TestFeatureSelectUniform.HackedConfig(cellSize);
// it should spread out the detections evenly throughout the cells
checkSpread(detected, cellSize, 1, found, alg);
checkSpread(detected, cellSize, 2, found, alg);
}
use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.
the class TestAssociateNearestNeighbor_ST method scoreRatio.
/**
* See if associations are skipped if the ratio is too low
*/
@Test
void scoreRatio() {
Dummy<TupleDesc_F64> nn = new Dummy<>();
// src = assoc[i] where src is the index of the source feature and i is the index of the dst feature
nn.assoc = new int[] { 2, 0, 1, -1, 4, -1, -1, 2, 2, 1 };
nn.distanceScale = 2.0;
AssociateNearestNeighbor_ST<TupleDesc_F64> alg = new AssociateNearestNeighbor_ST<>(nn, TupleDesc_F64.class);
FastArray<TupleDesc_F64> src = new FastArray<>(TupleDesc_F64.class);
FastArray<TupleDesc_F64> dst = new FastArray<>(TupleDesc_F64.class);
for (int i = 0; i < 5; i++) {
src.add(new TupleDesc_F64(10));
}
for (int i = 0; i < 10; i++) {
dst.add(new TupleDesc_F64(10));
}
alg.setSource(src);
alg.setDestination(dst);
alg.setRatioUsesSqrt(false);
// threshold should reject everything
alg.setScoreRatioThreshold(0.49);
alg.associate();
assertEquals(0, alg.getMatches().size);
// everything should be accepted
alg.setScoreRatioThreshold(0.51);
alg.associate();
assertEquals(10, alg.getMatches().size);
alg.setRatioUsesSqrt(true);
alg.setScoreRatioThreshold(1.0 / Math.sqrt(2.0) - 0.001);
alg.associate();
assertEquals(0, alg.getMatches().size);
alg.setScoreRatioThreshold(1.0 / Math.sqrt(2.0) + 0.001);
alg.associate();
assertEquals(10, alg.getMatches().size);
}
use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.
the class TestFeatureSelectUniformBest method everyCellHasPrior.
void everyCellHasPrior(boolean positive) {
int width = 30;
int height = 20;
// One detected feature in each cell and two priors
QueueCorner prior = new QueueCorner();
QueueCorner detected = new QueueCorner();
int cellSize = 10;
for (int y = 0; y < height; y += cellSize) {
for (int x = 0; x < width; x += cellSize) {
detected.grow().setTo(x + 2, y + 2);
prior.grow().setTo(x + 2, y + 2);
prior.grow().setTo(x + 1, y + 1);
}
}
var found = new FastArray<>(Point2D_I16.class);
FeatureSelectUniformBest<Point2D_I16> alg = createAlgorithm();
// make it easy to know the cell size
alg.configUniform = new HackedConfig(cellSize);
// a bug earlier aborted because the total count didn't change when every cell had a prior in it
alg.select(intensity, -1, -1, positive, prior, detected, 6, found);
assertEquals(6, found.size);
}
Aggregations