Search in sources :

Example 6 with ConfigExtract

use of boofcv.abst.feature.detect.extract.ConfigExtract in project BoofCV by lessthanoptimal.

the class DebugSiftDetectorApp method main.

public static void main(String[] args) {
    BufferedImage input = UtilImageIO.loadImage(UtilIO.pathExample("sunflowers.jpg"));
    // BufferedImage input = UtilImageIO.loadImage(UtilIO.pathExample("shapes/shapes01.png");
    GrayF32 gray = ConvertBufferedImage.convertFromSingle(input, null, GrayF32.class);
    NonMaxSuppression nonmax = FactoryFeatureExtractor.nonmax(new ConfigExtract(3, 1, 1, true, true, true));
    NonMaxLimiter extractor = new NonMaxLimiter(nonmax, 400);
    SiftScaleSpace imageSS = new SiftScaleSpace(-1, 5, 3, 2.75);
    SiftDetector alg = new SiftDetector(imageSS, 10, extractor);
    alg.process(gray);
    System.out.println("total features found: " + alg.getDetections().size());
    VisualizeFeatures.drawScalePoints(input.createGraphics(), alg.getDetections().toList(), 1);
    // ListDisplayPanel dog = new ListDisplayPanel();
    // for( int i = 0; i < alg.getScaleSpace().getDog().length; i++ ) {
    // int scale = i % (alg.getScaleSpace().getNumScales()-1);
    // int octave = i / (alg.getScaleSpace().getNumScales()-1);
    // 
    // BufferedImage img = VisualizeImageData.colorizeSign(alg.getScaleSpace().getDog()[i],null,-1);
    // dog.addImage(img,octave+"  "+scale);
    // }
    // 
    // ListDisplayPanel ss = new ListDisplayPanel();
    // for( int i = 0; i < alg.getScaleSpace().getScale().length; i++ ) {
    // int scale = i % alg.getScaleSpace().getNumScales();
    // int octave = i / alg.getScaleSpace().getNumScales();
    // 
    // BufferedImage img = VisualizeImageData.grayMagnitude(alg.getScaleSpace().getScale()[i],null,255);
    // ss.addImage(img,octave+"  "+scale);
    // }
    // ShowImages.showWindow(dog, "Octave DOG");
    // ShowImages.showWindow(ss, "Octave Scales");
    ShowImages.showWindow(input, "Found Features", true);
    System.out.println("Done");
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxLimiter(boofcv.abst.feature.detect.extract.NonMaxLimiter) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) GrayF32(boofcv.struct.image.GrayF32) SiftScaleSpace(boofcv.alg.feature.detect.interest.SiftScaleSpace) SiftDetector(boofcv.alg.feature.detect.interest.SiftDetector) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 7 with ConfigExtract

use of boofcv.abst.feature.detect.extract.ConfigExtract in project BoofCV by lessthanoptimal.

the class TestGeneralFeatureDetector method testDetection.

/**
 * Several basic detection tests
 */
@Test
public void testDetection() {
    // use a real extractor
    NonMaxSuppression extractor;
    HelperIntensity intensity = new HelperIntensity(false, false, false);
    // add several features while avoiding the image border
    intensity.img.set(1, 1, 10);
    intensity.img.set(7, 1, 10);
    intensity.img.set(1, 5, 10);
    intensity.img.set(7, 5, 10);
    intensity.img.set(1, 9, 10);
    intensity.img.set(6, 9, 10);
    // add a couple of minimums
    intensity.img.set(2, 5, -10);
    intensity.img.set(6, 5, -10);
    // configure it to only detect positive features
    intensity.minimums = false;
    extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(1, 0.001f, 1, true, false, true));
    GeneralFeatureDetector<GrayF32, GrayF32> detector = new GeneralFeatureDetector<>(intensity, extractor);
    detector.process(new GrayF32(width, height), null, null, null, null, null);
    assertEquals(6, detector.getMaximums().size());
    assertEquals(0, detector.getMinimums().size());
    // try detecting the negative features too
    intensity.minimums = true;
    extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(1, 0.001f, 1, true, true, true));
    detector = new GeneralFeatureDetector<>(intensity, extractor);
    detector.process(new GrayF32(width, height), null, null, null, null, null);
    assertEquals(6, detector.getMaximums().size());
    assertEquals(2, detector.getMinimums().size());
    // call it twice to make sure everything is reset correctly
    detector.process(new GrayF32(width, height), null, null, null, null, null);
    assertEquals(6, detector.getMaximums().size());
    assertEquals(2, detector.getMinimums().size());
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Example 8 with ConfigExtract

use of boofcv.abst.feature.detect.extract.ConfigExtract in project BoofCV by lessthanoptimal.

the class TestHoughTransformLineFootOfNorm method obviousLines.

private <D extends ImageGray<D>> void obviousLines(Class<D> derivType) {
    GrayU8 binary = new GrayU8(width, height);
    D derivX = GeneralizedImageOps.createSingleBand(derivType, width, height);
    D derivY = GeneralizedImageOps.createSingleBand(derivType, width, height);
    for (int i = 0; i < height; i++) {
        binary.set(5, i, 1);
        GeneralizedImageOps.set(derivX, 5, i, 20);
    }
    NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(4, 2, 0, true));
    HoughTransformLineFootOfNorm alg = new HoughTransformLineFootOfNorm(extractor, 2);
    alg.transform(derivX, derivY, binary);
    FastQueue<LineParametric2D_F32> lines = alg.extractLines();
    assertEquals(1, lines.size());
    LineParametric2D_F32 l = lines.get(0);
    assertEquals(l.p.x, 5, 0.1);
    // normalize the line for easier evaluation
    l.slope.x /= l.slope.norm();
    l.slope.y /= l.slope.norm();
    assertEquals(0, Math.abs(l.slope.x), 0);
    assertEquals(1, Math.abs(l.slope.y), 0.1);
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) LineParametric2D_F32(georegression.struct.line.LineParametric2D_F32)

Example 9 with ConfigExtract

use of boofcv.abst.feature.detect.extract.ConfigExtract in project BoofCV by lessthanoptimal.

the class TestGeneralFeatureDetector method ignoreBorder.

/**
 * If the intensity image has an ignore border is that border request actually followed?
 */
@Test
public void ignoreBorder() {
    HelperIntensity intensity = new HelperIntensity(false, false, false);
    intensity.ignoreBorder = 2;
    intensity.minimums = true;
    // add several features inside the image
    intensity.img.set(3, 3, 10);
    intensity.img.set(5, 5, 10);
    intensity.img.set(6, 7, 10);
    intensity.img.set(4, 7, -10);
    intensity.img.set(6, 8, -10);
    // add some along the border
    intensity.img.set(5, 1, 10);
    intensity.img.set(5, 11, 10);
    intensity.img.set(0, 5, 10);
    intensity.img.set(1, 1, 10);
    intensity.img.set(9, 5, 10);
    intensity.img.set(9, 4, -10);
    // use a real extractor
    NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(1, 0.001f, 1, true, true, true));
    GeneralFeatureDetector<GrayF32, GrayF32> detector = new GeneralFeatureDetector<>(intensity, extractor);
    detector.process(new GrayF32(width, height), null, null, null, null, null);
    // only features inside the image should be found
    assertEquals(3, detector.getMaximums().size());
    assertEquals(2, detector.getMinimums().size());
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Example 10 with ConfigExtract

use of boofcv.abst.feature.detect.extract.ConfigExtract in project BoofCV by lessthanoptimal.

the class VisualizeStereoVisualOdometryApp method createStereoDepth.

private StereoVisualOdometry<I> createStereoDepth(int whichAlg) {
    Class derivType = GImageDerivativeOps.getDerivativeType(imageType);
    StereoDisparitySparse<I> disparity = FactoryStereoDisparity.regionSparseWta(2, 150, 3, 3, 30, -1, true, imageType);
    PkltConfig kltConfig = new PkltConfig();
    kltConfig.templateRadius = 3;
    kltConfig.pyramidScaling = new int[] { 1, 2, 4, 8 };
    if (whichAlg == 0) {
        ConfigGeneralDetector configDetector = new ConfigGeneralDetector(600, 3, 1);
        PointTrackerTwoPass<I> tracker = FactoryPointTrackerTwoPass.klt(kltConfig, configDetector, imageType, derivType);
        return FactoryVisualOdometry.stereoDepth(1.5, 120, 2, 200, 50, false, disparity, tracker, imageType);
    } else if (whichAlg == 1) {
        ConfigGeneralDetector configExtract = new ConfigGeneralDetector(600, 3, 1);
        GeneralFeatureDetector detector = FactoryPointTracker.createShiTomasi(configExtract, derivType);
        DescribeRegionPoint describe = FactoryDescribeRegionPoint.brief(null, imageType);
        ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
        AssociateDescription2D<TupleDesc_B> associate = new AssociateDescTo2D<>(FactoryAssociation.greedy(score, 150, true));
        PointTrackerTwoPass tracker = FactoryPointTrackerTwoPass.dda(detector, describe, associate, null, 1, imageType);
        return FactoryVisualOdometry.stereoDepth(1.5, 80, 3, 200, 50, false, disparity, tracker, imageType);
    } else if (whichAlg == 2) {
        PointTracker<I> tracker = FactoryPointTracker.combined_ST_SURF_KLT(new ConfigGeneralDetector(600, 3, 0), kltConfig, 50, null, null, imageType, derivType);
        PointTrackerTwoPass<I> twopass = new PointTrackerToTwoPass<>(tracker);
        return FactoryVisualOdometry.stereoDepth(1.5, 80, 3, 200, 50, false, disparity, twopass, imageType);
    } else if (whichAlg == 3) {
        ConfigGeneralDetector configDetector = new ConfigGeneralDetector(600, 3, 1);
        PointTracker<I> trackerLeft = FactoryPointTracker.klt(kltConfig, configDetector, imageType, derivType);
        PointTracker<I> trackerRight = FactoryPointTracker.klt(kltConfig, configDetector, imageType, derivType);
        DescribeRegionPoint describe = FactoryDescribeRegionPoint.surfFast(null, imageType);
        return FactoryVisualOdometry.stereoDualTrackerPnP(90, 2, 1.5, 1.5, 200, 50, trackerLeft, trackerRight, describe, imageType);
    } else if (whichAlg == 4) {
        // GeneralFeatureIntensity intensity =
        // FactoryIntensityPoint.hessian(HessianBlobIntensity.Type.TRACE,defaultType);
        GeneralFeatureIntensity intensity = FactoryIntensityPoint.shiTomasi(1, false, imageType);
        NonMaxSuppression nonmax = FactoryFeatureExtractor.nonmax(new ConfigExtract(2, 50, 0, true, false, true));
        GeneralFeatureDetector general = new GeneralFeatureDetector(intensity, nonmax);
        general.setMaxFeatures(600);
        DetectorInterestPointMulti detector = new GeneralToInterestMulti(general, 2, imageType, derivType);
        // DescribeRegionPoint describe = FactoryDescribeRegionPoint.brief(new ConfigBrief(true),defaultType);
        // DescribeRegionPoint describe = FactoryDescribeRegionPoint.pixelNCC(5,5,defaultType);
        DescribeRegionPoint describe = FactoryDescribeRegionPoint.surfFast(null, imageType);
        DetectDescribeMulti detDescMulti = new DetectDescribeMultiFusion(detector, null, describe);
        return FactoryVisualOdometry.stereoQuadPnP(1.5, 0.5, 75, Double.MAX_VALUE, 300, 50, detDescMulti, imageType);
    } else {
        throw new RuntimeException("Unknown selection");
    }
}
Also used : NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) GeneralToInterestMulti(boofcv.abst.feature.detect.interest.GeneralToInterestMulti) PkltConfig(boofcv.alg.tracker.klt.PkltConfig) FactoryDescribeRegionPoint(boofcv.factory.feature.describe.FactoryDescribeRegionPoint) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) DetectDescribeMultiFusion(boofcv.abst.feature.detdesc.DetectDescribeMultiFusion) DetectorInterestPointMulti(boofcv.abst.feature.detect.interest.DetectorInterestPointMulti) ScoreAssociateHamming_B(boofcv.abst.feature.associate.ScoreAssociateHamming_B) FactoryPointTrackerTwoPass(boofcv.factory.feature.tracker.FactoryPointTrackerTwoPass) PointTrackerTwoPass(boofcv.abst.feature.tracker.PointTrackerTwoPass) ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) DetectDescribeMulti(boofcv.abst.feature.detdesc.DetectDescribeMulti) GeneralFeatureDetector(boofcv.alg.feature.detect.interest.GeneralFeatureDetector) PointTrackerToTwoPass(boofcv.abst.feature.tracker.PointTrackerToTwoPass) AssociateDescription2D(boofcv.abst.feature.associate.AssociateDescription2D) PointTracker(boofcv.abst.feature.tracker.PointTracker) FactoryPointTracker(boofcv.factory.feature.tracker.FactoryPointTracker) GeneralFeatureIntensity(boofcv.abst.feature.detect.intensity.GeneralFeatureIntensity)

Aggregations

ConfigExtract (boofcv.abst.feature.detect.extract.ConfigExtract)20 NonMaxSuppression (boofcv.abst.feature.detect.extract.NonMaxSuppression)19 GrayF32 (boofcv.struct.image.GrayF32)6 NonMaxLimiter (boofcv.abst.feature.detect.extract.NonMaxLimiter)3 GeneralFeatureDetector (boofcv.alg.feature.detect.interest.GeneralFeatureDetector)3 QueueCorner (boofcv.struct.QueueCorner)3 Point2D_I16 (georegression.struct.point.Point2D_I16)3 Test (org.junit.Test)3 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)2 DetectDescribeMulti (boofcv.abst.feature.detdesc.DetectDescribeMulti)2 DetectDescribeMultiFusion (boofcv.abst.feature.detdesc.DetectDescribeMultiFusion)2 GeneralFeatureIntensity (boofcv.abst.feature.detect.intensity.GeneralFeatureIntensity)2 WrapperGradientCornerIntensity (boofcv.abst.feature.detect.intensity.WrapperGradientCornerIntensity)2 WrapperHessianBlobIntensity (boofcv.abst.feature.detect.intensity.WrapperHessianBlobIntensity)2 DetectorInterestPointMulti (boofcv.abst.feature.detect.interest.DetectorInterestPointMulti)2 GeneralToInterestMulti (boofcv.abst.feature.detect.interest.GeneralToInterestMulti)2 FastHessianFeatureDetector (boofcv.alg.feature.detect.interest.FastHessianFeatureDetector)2 SiftScaleSpace (boofcv.alg.feature.detect.interest.SiftScaleSpace)2 FactoryDescribeRegionPoint (boofcv.factory.feature.describe.FactoryDescribeRegionPoint)2 FactoryIntensityPoint (boofcv.factory.feature.detect.intensity.FactoryIntensityPoint)2