Search in sources :

Example 6 with QueueCorner

use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.

the class TestFeatureSelectUniformBest method checkAcknowledgePrior.

void checkAcknowledgePrior(boolean positive) {
    int width = 30;
    int height = 20;
    // One detected feature in each cell
    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);
        }
    }
    // add two prior features to the top row
    for (int x = 0; x < width; x += cellSize) {
        prior.grow().setTo(x + 2, 2);
        prior.grow().setTo(x + 2, 2);
    }
    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);
    // Since there is a prior feature in every cell and 6 features were requested nothing should be returned
    // since the prior features already constributed to the spread
    alg.select(intensity, -1, -1, positive, prior, detected, 3, found);
    assertEquals(3, found.size);
    // the found features should all be in the bottom row since it gives preference to cells without priors
    for (int x = 0, idx = 0; x < width; x += cellSize, idx++) {
        assertEquals(x + 2, found.get(idx).x);
        assertEquals(12, found.get(idx).y);
    }
    // We now request two and 6 of the detected features should be returned
    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 7 with QueueCorner

use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.

the class TestFeatureSelectUniform method everyCellHasPrior.

/**
 * Every cell has a prior in it. make sure it doesn't get messed up.
 */
@Test
void everyCellHasPrior() {
    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);
    FeatureSelectUniform<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(width, height, 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) Test(org.junit.jupiter.api.Test)

Example 8 with QueueCorner

use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.

the class TestThresholdCornerExtractor method testThreshold.

public void testThreshold(GrayF32 img) {
    ThresholdCornerExtractor extractor = new ThresholdCornerExtractor(1.5F);
    QueueCorner corners = new QueueCorner(100);
    extractor.process(img, corners);
    assertEquals(7, corners.size());
}
Also used : QueueCorner(boofcv.struct.QueueCorner)

Example 9 with QueueCorner

use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.

the class FeatureLaplacePyramid method detectCandidateFeatures.

/**
 * Use the feature detector to find candidate features in each level. Only compute the needed image derivatives.
 */
private void detectCandidateFeatures(T image, double sigma) {
    // adjust corner intensity threshold based upon the current scale factor
    float scaleThreshold = (float) (baseThreshold / Math.pow(sigma, scalePower));
    detector.setThreshold(scaleThreshold);
    computeDerivative.setInput(image);
    D derivX = null, derivY = null;
    D derivXX = null, derivYY = null, derivXY = null;
    if (detector.getRequiresGradient()) {
        derivX = computeDerivative.getDerivative(true);
        derivY = computeDerivative.getDerivative(false);
    }
    if (detector.getRequiresHessian()) {
        derivXX = computeDerivative.getDerivative(true, true);
        derivYY = computeDerivative.getDerivative(false, false);
        derivXY = computeDerivative.getDerivative(true, false);
    }
    detector.process(image, derivX, derivY, derivXX, derivYY, derivXY);
    List<Point2D_I16> m = maximums;
    m.clear();
    if (detector.isDetectMaximums()) {
        QueueCorner q = detector.getMaximums();
        for (int i = 0; i < q.size; i++) {
            m.add(q.get(i).copy());
        }
    }
    if (detector.isDetectMinimums()) {
        QueueCorner q = detector.getMinimums();
        for (int i = 0; i < q.size; i++) {
            m.add(q.get(i).copy());
        }
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) ScalePoint(boofcv.struct.feature.ScalePoint)

Example 10 with QueueCorner

use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.

the class NonMaxBlock_MT method process.

/**
 * Detects local minimums and/or maximums in the provided intensity image.
 *
 * @param intensityImage (Input) Feature intensity image.
 * @param localMin (Output) storage for found local minimums.
 * @param localMax (Output) storage for found local maximums.
 */
@Override
public void process(GrayF32 intensityImage, @Nullable QueueCorner localMin, @Nullable QueueCorner localMax) {
    if (localMin != null)
        localMin.reset();
    if (localMax != null)
        localMax.reset();
    // the defines the region that can be processed
    int endX = intensityImage.width - border;
    int endY = intensityImage.height - border;
    int step = configuration.radius + 1;
    search.initialize(configuration, intensityImage, localMin, localMax);
    // Compute number of y iterations
    int range = endY - border;
    int N = range / step;
    if (range > N * step)
        N += 1;
    // The previous version required locks. In a benchmark in Java 11 this lock free version and the previous
    // had identical performance.
    BoofConcurrency.loopBlocks(0, N, searches, (blockInfo, iter0, iter1) -> {
        final Search search = blockInfo.search;
        blockInfo.cornersMin.reset();
        blockInfo.cornersMax.reset();
        QueueCorner threadMin = localMin != null ? blockInfo.cornersMin : null;
        QueueCorner threadMax = localMax != null ? blockInfo.cornersMax : null;
        search.initialize(configuration, intensityImage, threadMin, threadMax);
        for (int iterY = iter0; iterY < iter1; iterY++) {
            // search for local peaks along this block row
            int y = border + iterY * step;
            int y1 = y + step;
            if (y1 > endY)
                y1 = endY;
            for (int x = border; x < endX; x += step) {
                int x1 = x + step;
                if (x1 > endX)
                    x1 = endX;
                search.searchBlock(x, y, x1, y1);
            }
        }
    });
    // on results that needed to be deterministic
    for (int i = 0; i < searches.size(); i++) {
        SearchData data = searches.get(i);
        if (localMin != null)
            localMin.appendAll(data.cornersMin);
        if (localMax != null)
            localMax.appendAll(data.cornersMax);
    }
}
Also used : QueueCorner(boofcv.struct.QueueCorner)

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