Search in sources :

Example 16 with QueueCorner

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

the class GeneralTemplateMatchTests method checkExpected.

private void checkExpected(Point2D_I32... points) {
    // I'm being lazy, update this in the future
    assertFalse(alg.isBorderProcessed());
    // only process the regions which are not considered the border
    int x0 = alg.getBorderX0();
    int y0 = alg.getBorderY0();
    // solutions should be local maximums
    NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(2, -Float.MAX_VALUE, 0, true));
    QueueCorner found = new QueueCorner(10);
    extractor.process(alg.getIntensity(), null, null, null, found);
    assertTrue(found.size >= points.length);
    // search for all the expected matches
    for (Point2D_I32 expected : points) {
        int numMatches = 0;
        for (Point2D_I16 f : found.toList()) {
            double d = UtilPoint2D_F64.distance(f.x - x0, f.y - y0, expected.x, expected.y);
            if (d <= 1)
                numMatches++;
        }
        assertEquals(1, numMatches);
    }
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) Point2D_I32(georegression.struct.point.Point2D_I32)

Example 17 with QueueCorner

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

the class TestSelectNBestFeatures method testExtra.

/**
 * The value of N is less than the number of features
 */
@Test
public void testExtra() {
    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 corners = new QueueCorner();
    corners.add(5, 10);
    corners.add(4, 10);
    corners.add(5, 11);
    corners.add(8, 8);
    SelectNBestFeatures alg = new SelectNBestFeatures(20);
    alg.setN(3);
    alg.process(intensity, corners, true);
    QueueCorner found = alg.getBestCorners();
    assertEquals(3, found.size);
    assertEquals(8, found.get(0).x);
    assertEquals(8, found.get(0).y);
    // same test, but with negative features
    alg.process(intensity, corners, false);
    found = alg.getBestCorners();
    assertEquals(3, found.size);
    assertEquals(4, found.get(0).x);
    assertEquals(10, found.get(0).y);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) QueueCorner(boofcv.struct.QueueCorner) Test(org.junit.Test)

Example 18 with QueueCorner

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

the class TestSelectNBestFeatures method testTooLittle.

/**
 * The size of N is less than the number of points
 */
@Test
public void testTooLittle() {
    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 corners = new QueueCorner();
    corners.add(5, 10);
    corners.add(4, 10);
    corners.add(5, 11);
    corners.add(8, 8);
    SelectNBestFeatures alg = new SelectNBestFeatures(20);
    alg.setN(20);
    alg.process(intensity, corners, true);
    QueueCorner found = alg.getBestCorners();
    assertEquals(4, found.size);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) QueueCorner(boofcv.struct.QueueCorner) Test(org.junit.Test)

Example 19 with QueueCorner

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

the class ShowFeatureOrientationApp method setActiveAlgorithm.

@Override
public synchronized void setActiveAlgorithm(int indexFamily, String name, Object cookie) {
    if (input == null)
        return;
    RegionOrientation orientation = (RegionOrientation) cookie;
    orientation.setObjectRadius(10);
    T workImage = ConvertBufferedImage.convertFromSingle(input, null, imageType);
    AnyImageDerivative<T, D> deriv = GImageDerivativeOps.derivativeForScaleSpace(imageType, derivType);
    deriv.setInput(workImage);
    int r = 2;
    GeneralFeatureDetector<T, D> detector = FactoryDetectPoint.createHarris(new ConfigGeneralDetector(NUM_FEATURES, r, 1), null, derivType);
    D derivX = null, derivY = null, derivXX = null, derivYY = null, derivXY = null;
    if (detector.getRequiresGradient()) {
        derivX = deriv.getDerivative(true);
        derivY = deriv.getDerivative(false);
    } else if (detector.getRequiresHessian()) {
        derivXX = deriv.getDerivative(true, true);
        derivYY = deriv.getDerivative(false, false);
        derivXY = deriv.getDerivative(true, false);
    }
    detector.process(workImage, derivX, derivY, derivXX, derivYY, derivXY);
    QueueCorner points = detector.getMaximums();
    FancyInterestPointRender render = new FancyInterestPointRender();
    if (orientation instanceof OrientationGradient) {
        ((OrientationGradient<D>) orientation).setImage(deriv.getDerivative(true), deriv.getDerivative(false));
    } else if (orientation instanceof OrientationIntegral) {
        T ii = GIntegralImageOps.transform(workImage, null);
        ((OrientationIntegral<T>) orientation).setImage(ii);
    } else if (orientation instanceof OrientationImageAverage) {
        ((OrientationImageAverage) orientation).setImage(workImage);
    } else {
        throw new IllegalArgumentException("Unknown algorithm type.");
    }
    for (int i = 0; i < points.size; i++) {
        Point2D_I16 p = points.get(i);
        double angle = orientation.compute(p.x, p.y);
        render.addCircle(p.x, p.y, radius, Color.RED, angle);
    }
    BufferedImage temp = new BufferedImage(input.getWidth(), input.getHeight(), input.getType());
    Graphics2D g2 = (Graphics2D) temp.getGraphics();
    g2.drawImage(input, 0, 0, null);
    g2.setStroke(new BasicStroke(2.5f));
    render.draw(g2);
    panel.setImage(temp);
    panel.repaint();
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) FancyInterestPointRender(boofcv.gui.feature.FancyInterestPointRender) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) OrientationImageAverage(boofcv.alg.feature.orientation.OrientationImageAverage) FactoryDetectPoint(boofcv.factory.feature.detect.interest.FactoryDetectPoint) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) QueueCorner(boofcv.struct.QueueCorner)

Example 20 with QueueCorner

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

the class BenchmarkExtractors method setup.

@Setup
public void setup() {
    BoofConcurrency.USE_CONCURRENT = concurrent;
    intensity.reshape(width, width);
    corners = new QueueCorner();
    Random rand = new Random(234);
    ImageMiscOps.fillUniform(intensity, rand, 0, 200);
    ConfigExtract config = new ConfigExtract();
    config.radius = radius;
    config.detectMaximums = true;
    config.detectMinimums = false;
    config.threshold = threshold;
    config.useStrictRule = true;
    blockStrictMax = FactoryFeatureExtractor.nonmax(config);
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) QueueCorner(boofcv.struct.QueueCorner) Random(java.util.Random)

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