Search in sources :

Example 1 with QueueCorner

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

the class GeneralToInterestMulti method detect.

@Override
public void detect(T input) {
    foundMin.reset();
    foundMax.reset();
    detector.detect(input, null);
    QueueCorner min = detector.getMinimums();
    for (int i = 0; i < min.size; i++) {
        Point2D_I16 p = min.get(i);
        foundMin.grow().set(p.x, p.y);
    }
    QueueCorner max = detector.getMaximums();
    for (int i = 0; i < max.size; i++) {
        Point2D_I16 p = max.get(i);
        foundMax.grow().set(p.x, p.y);
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner)

Example 2 with QueueCorner

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

the class CompareFeatureExtractorApp method doProcess.

private synchronized void doProcess() {
    // System.out.println("radius "+radius+" min separation "+minSeparation+" thresholdFraction "+thresholdFraction+" numFeatures "+numFeatures);
    deriv.setInput(grayImage);
    D derivX = deriv.getDerivative(true);
    D derivY = deriv.getDerivative(false);
    D derivXX = deriv.getDerivative(true, true);
    D derivYY = deriv.getDerivative(false, false);
    D derivXY = deriv.getDerivative(true, false);
    // todo modifying buffered images which might be actively being displayed, could mess up swing
    intensityAlg.process(grayImage, derivX, derivY, derivXX, derivYY, derivXY);
    GrayF32 intensity = intensityAlg.getIntensity();
    intensityImage = VisualizeImageData.colorizeSign(intensityAlg.getIntensity(), null, ImageStatistics.maxAbs(intensity));
    float max = ImageStatistics.maxAbs(intensity);
    float threshold = max * thresholdFraction;
    NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(minSeparation, threshold, radius, true));
    GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensityAlg, extractor);
    detector.setMaxFeatures(numFeatures);
    detector.process(grayImage, derivX, derivY, derivXX, derivYY, derivXY);
    QueueCorner foundCorners = detector.getMaximums();
    render.reset();
    for (int i = 0; i < foundCorners.size(); i++) {
        Point2D_I16 p = foundCorners.get(i);
        render.addPoint(p.x, p.y, 3, Color.RED);
    }
    Graphics2D g2 = workImage.createGraphics();
    g2.drawImage(input, 0, 0, grayImage.width, grayImage.height, null);
    render.draw(g2);
    drawImage();
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) GrayF32(boofcv.struct.image.GrayF32) Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) GeneralFeatureDetector(boofcv.alg.feature.detect.interest.GeneralFeatureDetector) FactoryIntensityPoint(boofcv.factory.feature.detect.intensity.FactoryIntensityPoint)

Example 3 with QueueCorner

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

the class DdaManagerGeneralPoint method detectFeatures.

@Override
public void detectFeatures(I input, FastQueue<Point2D_F64> locDst, FastQueue<Desc> featDst) {
    // detect features in the image
    detector.detect(input, null);
    describe.setImage(input);
    QueueCorner found = detector.getMaximums();
    // compute descriptors and populate results list
    descriptors.reset();
    locations.reset();
    for (int i = 0; i < found.size; i++) {
        Point2D_I16 p = found.get(i);
        Desc desc = descriptors.grow();
        if (describe.process(p.x, p.y, 0, scale, desc)) {
            Point2D_F64 loc = locations.grow();
            loc.set(p.x, p.y);
            describe.process(loc.x, loc.y, 0, scale, desc);
            featDst.add(desc);
            locDst.add(loc);
        } else {
            descriptors.removeTail();
        }
    }
}
Also used : TupleDesc(boofcv.struct.feature.TupleDesc) Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) Point2D_F64(georegression.struct.point.Point2D_F64) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint)

Example 4 with QueueCorner

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

the class GenericNonMaxAlgorithmTests method compareToNaive.

/**
 * Compares output against naive algorithm.  Checks for compliance with sub-images
 */
@Test
public void compareToNaive() {
    GrayF32 inten = new GrayF32(30, 40);
    QueueCorner naiveMin = new QueueCorner(inten.getWidth() * inten.getHeight());
    QueueCorner naiveMax = new QueueCorner(inten.getWidth() * inten.getHeight());
    for (int useSubImage = 0; useSubImage <= 1; useSubImage++) {
        // make sure it handles sub images correctly
        if (useSubImage == 1) {
            GrayF32 larger = new GrayF32(inten.width + 10, inten.height + 8);
            inten = larger.subimage(5, 5, inten.width + 5, inten.height + 5, null);
        }
        for (int nonMaxWidth = 3; nonMaxWidth <= 9; nonMaxWidth += 2) {
            int radius = nonMaxWidth / 2;
            NonMaxExtractorNaive reg = new NonMaxExtractorNaive(strict);
            reg.setSearchRadius(radius);
            reg.setThreshold(0.6f);
            for (int i = 0; i < 10; i++) {
                ImageMiscOps.fillGaussian(inten, rand, 0, 3, -100, 100);
                // detect the corners
                findLocalPeaks(inten, 0.6f, radius, 0);
                naiveMin.reset();
                naiveMax.reset();
                reg.process(inten, naiveMax);
                PixelMath.invert(inten, inten);
                reg.process(inten, naiveMin);
                // check the number of corners
                if (canDetectMin) {
                    assertTrue(foundMinimum.size() > 0);
                    assertEquals(naiveMin.size(), foundMinimum.size());
                    checkSamePoints(naiveMin, foundMinimum);
                }
                if (canDetectMax) {
                    assertTrue(foundMaximum.size() > 0);
                    assertEquals(naiveMax.size(), foundMaximum.size());
                    checkSamePoints(naiveMax, foundMaximum);
                }
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) QueueCorner(boofcv.struct.QueueCorner) Test(org.junit.Test)

Example 5 with QueueCorner

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

the class ExampleCornerFeature method main.

public static void main(String[] args) {
    ConfigGeneralDetector configNonMax = new ConfigGeneralDetector();
    // a large radius is used to exaggerate weighted/unweighted affects. Try 1 or 2 for a typical value
    configNonMax.radius = 10;
    configNonMax.threshold = 100;
    configNonMax.maxFeatures = 100;
    ConfigShiTomasi configCorner = new ConfigShiTomasi();
    // in general you should use the same radius here
    configCorner.radius = configNonMax.radius;
    // weighted corners will appear at the corners on a chessboard
    configCorner.weighted = true;
    // set weighted to false and see what happens to the feature's locations. unweighted is much faster
    GeneralFeatureDetector<GrayU8, GrayS16> detector = FactoryDetectPoint.createShiTomasi(configNonMax, configCorner, GrayS16.class);
    ImageGradient<GrayU8, GrayS16> sobel = FactoryDerivative.sobel(GrayU8.class, GrayS16.class);
    BufferedImage image = UtilImageIO.loadImageNotNull(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_Chess/frame05.jpg"));
    // Convert the image into a usable format and predeclare memory
    GrayU8 gray = ConvertBufferedImage.convertFrom(image, (GrayU8) null);
    GrayS16 derivX = new GrayS16(gray.width, gray.height);
    GrayS16 derivY = new GrayS16(gray.width, gray.height);
    // The first image derivatives are needed
    sobel.process(gray, derivX, derivY);
    // Compute the corners
    detector.process(gray, derivX, derivY, null, null, null);
    // Visualize the results
    QueueCorner corners = detector.getMaximums();
    Graphics2D g2 = image.createGraphics();
    for (int i = 0; i < corners.size; i++) {
        Point2D_I16 c = corners.get(i);
        VisualizeFeatures.drawPoint(g2, c.x, c.y, 4, Color.RED, true);
    }
    ShowImages.showWindow(image, "Corners", true);
}
Also used : ConfigShiTomasi(boofcv.abst.feature.detect.interest.ConfigShiTomasi) Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) GrayS16(boofcv.struct.image.GrayS16) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) GrayU8(boofcv.struct.image.GrayU8) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) FactoryDetectPoint(boofcv.factory.feature.detect.interest.FactoryDetectPoint)

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