use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class TestEasyGeneralFeatureDetector method checkExclude.
@Test
void checkExclude() {
Helper<GrayU8, GrayS16> detector = new Helper<>(true, true);
EasyGeneralFeatureDetector<GrayU8, GrayS16> alg = new EasyGeneralFeatureDetector<>(detector, GrayU8.class, GrayS16.class);
alg.detect(image, new QueueCorner(10));
assertFalse(detector.excludeIsNull);
}
use of boofcv.struct.QueueCorner 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);
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class TestFeatureSelectUniformBest method checkAllCells.
private void checkAllCells(boolean positive) {
float largeValue = positive ? 5 : -5;
// 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;
for (int y = 0; y < height; y += cellSize) {
for (int x = 0; x < width; x += cellSize) {
intensity.set(x + 2, y + 2, largeValue);
}
}
// this one corner will by far have the most intense features
for (int y = 0; y < cellSize; y++) {
for (int x = 0; x < cellSize; x++) {
intensity.set(x, y, intensity.get(x, y) + largeValue * 4);
}
}
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);
// it should spread out the detections evenly throughout the cells
checkSpread(positive, detected, cellSize, 1, found, alg);
// The ones it selects should be the ones with the large values
for (int y = 0; y < height; y += cellSize) {
for (int x = 0; x < width; x += cellSize) {
checkInside(x + 2, y + 2, found);
}
}
checkSpread(positive, detected, cellSize, 2, found, alg);
// The ones it selects should be the ones with the large values
for (int y = 0; y < height; y += cellSize) {
for (int x = 0; x < width; x += cellSize) {
checkInside(x + 2, y + 2, found);
}
}
}
use of boofcv.struct.QueueCorner 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 boofcv.struct.QueueCorner 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);
}
Aggregations