Search in sources :

Example 1 with ConfigLineRansac

use of boofcv.factory.feature.detect.line.ConfigLineRansac in project BoofCV by lessthanoptimal.

the class BenchmarkDetectLines method setup.

@Setup
public void setup() {
    BoofConcurrency.USE_CONCURRENT = concurrent;
    // fill it with a few rectangles so that there are some lines
    input.reshape(width, width);
    GImageMiscOps.fill(input, 0);
    GImageMiscOps.fillRectangle(input, 100, 10, 15, width / 4, width / 4);
    GImageMiscOps.fillRectangle(input, 100, width / 2, width / 2 + 15, width / 4, width / 4);
    GImageMiscOps.fillRectangle(input, 100, width / 2, 0, width / 8, width / 8);
    GImageMiscOps.addUniform(input, new Random(234), 0, 20);
    houghFoot = FactoryDetectLine.houghLineFoot(null, null, imageType);
    houghPolar = FactoryDetectLine.houghLinePolar((ConfigHoughGradient) null, null, imageType);
    houghFootSub = FactoryDetectLine.houghLineFootSub(null, imageType);
    detectorSegment = FactoryDetectLine.lineRansac(new ConfigLineRansac(40, 30, 2.36, true), imageType);
}
Also used : ConfigLineRansac(boofcv.factory.feature.detect.line.ConfigLineRansac) Random(java.util.Random) ConfigHoughGradient(boofcv.factory.feature.detect.line.ConfigHoughGradient)

Example 2 with ConfigLineRansac

use of boofcv.factory.feature.detect.line.ConfigLineRansac in project BoofCV by lessthanoptimal.

the class DetectLineApp method declareDetector.

private void declareDetector() {
    synchronized (lockDetector) {
        lineDetector = null;
        segmentDetector = null;
        ConfigHoughGradient configGradient = new ConfigHoughGradient();
        configGradient.maxLines = controls.maxLines;
        switch(controls.whichAlg) {
            case 0:
                lineDetector = FactoryDetectLine.houghLinePolar(configGradient, null, imageType);
                break;
            case 1:
                lineDetector = FactoryDetectLine.houghLineFoot(configGradient, null, imageType);
                break;
            case 2:
                lineDetector = FactoryDetectLine.houghLineFootSub(new ConfigHoughFootSubimage(3, 8, 5, edgeThreshold, controls.maxLines, 2, 2), imageType);
                break;
            case 3:
                segmentDetector = FactoryDetectLine.lineRansac(new ConfigLineRansac(40, 30, 2.36, true), imageType);
                break;
        }
    }
}
Also used : ConfigLineRansac(boofcv.factory.feature.detect.line.ConfigLineRansac) ConfigHoughGradient(boofcv.factory.feature.detect.line.ConfigHoughGradient) ConfigHoughFootSubimage(boofcv.factory.feature.detect.line.ConfigHoughFootSubimage)

Example 3 with ConfigLineRansac

use of boofcv.factory.feature.detect.line.ConfigLineRansac in project MtgDesktopCompanion by nicho92.

the class RadiusAreaStrat method lineRansac.

/**
 * Derived from the BoofCV factory source code, but exposes
 * the RANSAC iterations and the max lines per grid region
 */
private DetectLineSegmentsGridRansac<GrayU8, GrayS16> lineRansac(ConfigLineRansac config, int maxIter, int maxLines) {
    if (config == null)
        config = new ConfigLineRansac();
    ImageGradient<GrayU8, GrayS16> gradient = FactoryDerivative.sobel(GrayU8.class, GrayS16.class);
    var manager = new ModelManagerLinePolar2D_F32();
    var distance = new GridLineModelDistance((float) config.thresholdAngle);
    var fitter = new GridLineModelFitter((float) config.thresholdAngle);
    ModelMatcher<LinePolar2D_F32, Edgel> matcher = new Ransac<>(123123, manager, fitter, distance, maxIter, 0.25);
    GridRansacLineDetector<GrayS16> alg = new ImplGridRansacLineDetector_S16(config.regionSize, maxLines, matcher);
    ConnectLinesGrid connect = null;
    if (config.connectLines)
        connect = new ConnectLinesGrid(Math.PI * 0.01, 1, 8);
    return new DetectLineSegmentsGridRansac<>(alg, connect, gradient, config.thresholdEdge, GrayU8.class, GrayS16.class);
}
Also used : LinePolar2D_F32(georegression.struct.line.LinePolar2D_F32) ModelManagerLinePolar2D_F32(georegression.fitting.line.ModelManagerLinePolar2D_F32) ModelManagerLinePolar2D_F32(georegression.fitting.line.ModelManagerLinePolar2D_F32) ImplGridRansacLineDetector_S16(boofcv.alg.feature.detect.line.gridline.ImplGridRansacLineDetector_S16) GrayS16(boofcv.struct.image.GrayS16) GridLineModelDistance(boofcv.alg.feature.detect.line.gridline.GridLineModelDistance) DetectLineSegmentsGridRansac(boofcv.abst.feature.detect.line.DetectLineSegmentsGridRansac) ConfigLineRansac(boofcv.factory.feature.detect.line.ConfigLineRansac) Ransac(org.ddogleg.fitting.modelset.ransac.Ransac) ConfigLineRansac(boofcv.factory.feature.detect.line.ConfigLineRansac) DetectLineSegmentsGridRansac(boofcv.abst.feature.detect.line.DetectLineSegmentsGridRansac) Edgel(boofcv.alg.feature.detect.line.gridline.Edgel) ConnectLinesGrid(boofcv.alg.feature.detect.line.ConnectLinesGrid) GrayU8(boofcv.struct.image.GrayU8) GridLineModelFitter(boofcv.alg.feature.detect.line.gridline.GridLineModelFitter)

Example 4 with ConfigLineRansac

use of boofcv.factory.feature.detect.line.ConfigLineRansac in project BoofCV by lessthanoptimal.

the class ExampleLineDetection method detectLineSegments.

/**
 * Detects segments inside the image
 *
 * @param image Input image.
 * @param imageType Type of image processed by line detector.
 */
public static <T extends ImageGray<T>, D extends ImageGray<D>> void detectLineSegments(BufferedImage image, Class<T> imageType) {
    // convert the line into a single band image
    T input = ConvertBufferedImage.convertFromSingle(image, null, imageType);
    // Comment/uncomment to try a different type of line detector
    DetectLineSegment<T> detector = FactoryDetectLine.lineRansac(new ConfigLineRansac(40, 30, 2.36, true), imageType);
    List<LineSegment2D_F32> found = detector.detect(input);
    // display the results
    ImageLinePanel gui = new ImageLinePanel();
    gui.setImage(image);
    gui.setLineSegments(found);
    gui.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
    listPanel.addItem(gui, "Line Segments");
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) ConfigLineRansac(boofcv.factory.feature.detect.line.ConfigLineRansac) ImageLinePanel(boofcv.gui.feature.ImageLinePanel)

Aggregations

ConfigLineRansac (boofcv.factory.feature.detect.line.ConfigLineRansac)4 ConfigHoughGradient (boofcv.factory.feature.detect.line.ConfigHoughGradient)2 DetectLineSegmentsGridRansac (boofcv.abst.feature.detect.line.DetectLineSegmentsGridRansac)1 ConnectLinesGrid (boofcv.alg.feature.detect.line.ConnectLinesGrid)1 Edgel (boofcv.alg.feature.detect.line.gridline.Edgel)1 GridLineModelDistance (boofcv.alg.feature.detect.line.gridline.GridLineModelDistance)1 GridLineModelFitter (boofcv.alg.feature.detect.line.gridline.GridLineModelFitter)1 ImplGridRansacLineDetector_S16 (boofcv.alg.feature.detect.line.gridline.ImplGridRansacLineDetector_S16)1 ConfigHoughFootSubimage (boofcv.factory.feature.detect.line.ConfigHoughFootSubimage)1 ImageLinePanel (boofcv.gui.feature.ImageLinePanel)1 GrayS16 (boofcv.struct.image.GrayS16)1 GrayU8 (boofcv.struct.image.GrayU8)1 ModelManagerLinePolar2D_F32 (georegression.fitting.line.ModelManagerLinePolar2D_F32)1 LinePolar2D_F32 (georegression.struct.line.LinePolar2D_F32)1 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)1 Random (java.util.Random)1 Ransac (org.ddogleg.fitting.modelset.ransac.Ransac)1