Search in sources :

Example 26 with QueueCorner

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);
}
Also used : QueueCorner(boofcv.struct.QueueCorner) GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.jupiter.api.Test)

Example 27 with QueueCorner

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);
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) FastArray(org.ddogleg.struct.FastArray)

Example 28 with QueueCorner

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);
        }
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) FastArray(org.ddogleg.struct.FastArray)

Example 29 with QueueCorner

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);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) FastArray(org.ddogleg.struct.FastArray) Test(org.junit.jupiter.api.Test)

Example 30 with QueueCorner

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);
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) FastArray(org.ddogleg.struct.FastArray) Test(org.junit.jupiter.api.Test)

Aggregations

QueueCorner (boofcv.struct.QueueCorner)30 Point2D_I16 (georegression.struct.point.Point2D_I16)21 GrayF32 (boofcv.struct.image.GrayF32)7 FastArray (org.ddogleg.struct.FastArray)6 ConfigExtract (boofcv.abst.feature.detect.extract.ConfigExtract)5 Test (org.junit.jupiter.api.Test)5 NonMaxSuppression (boofcv.abst.feature.detect.extract.NonMaxSuppression)4 FactoryDetectPoint (boofcv.factory.feature.detect.interest.FactoryDetectPoint)3 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 BufferedImage (java.awt.image.BufferedImage)3 Test (org.junit.Test)3 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)2 FactoryIntensityPoint (boofcv.factory.feature.detect.intensity.FactoryIntensityPoint)2 ScalePoint (boofcv.struct.feature.ScalePoint)2 GrayS16 (boofcv.struct.image.GrayS16)2 GrayU8 (boofcv.struct.image.GrayU8)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)1 ConfigShiTomasi (boofcv.abst.feature.detect.interest.ConfigShiTomasi)1 EasyGeneralFeatureDetector (boofcv.alg.feature.detect.interest.EasyGeneralFeatureDetector)1