Search in sources :

Example 1 with ConfigHoughGradient

use of boofcv.factory.feature.detect.line.ConfigHoughGradient 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 ConfigHoughGradient

use of boofcv.factory.feature.detect.line.ConfigHoughGradient 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 ConfigHoughGradient

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

the class ExampleLineDetection method detectLines.

/**
 * Detects lines inside the image using different types of Hough detectors
 *
 * @param buffered Input image.
 * @param imageType Type of image processed by line detector.
 */
public static <T extends ImageGray<T>> void detectLines(BufferedImage buffered, Class<T> imageType) {
    // convert the line into a single band image
    T input = ConvertBufferedImage.convertFromSingle(buffered, null, imageType);
    T blurred = input.createSameShape();
    // Blur smooths out gradient and improves results
    GBlurImageOps.gaussian(input, blurred, 0, 5, null);
    // Detect edges of objects using gradient based hough detectors. If you have nice binary lines which are thin
    // there's another type of hough detector available
    DetectLine<T> detectorPolar = FactoryDetectLine.houghLinePolar(new ConfigHoughGradient(maxLines), null, imageType);
    DetectLine<T> detectorFoot = FactoryDetectLine.houghLineFoot(new ConfigHoughGradient(maxLines), null, imageType);
    DetectLine<T> detectorFootSub = FactoryDetectLine.houghLineFootSub(new ConfigHoughFootSubimage(3, 8, 5, edgeThreshold, maxLines, 2, 2), imageType);
    detectLines(buffered, blurred, detectorPolar, "Hough Polar");
    detectLines(buffered, blurred, detectorFoot, "Hough Foot");
    detectLines(buffered, blurred, detectorFootSub, "Hough Foot-Sub");
}
Also used : ConfigHoughGradient(boofcv.factory.feature.detect.line.ConfigHoughGradient) ConfigHoughFootSubimage(boofcv.factory.feature.detect.line.ConfigHoughFootSubimage)

Aggregations

ConfigHoughGradient (boofcv.factory.feature.detect.line.ConfigHoughGradient)3 ConfigHoughFootSubimage (boofcv.factory.feature.detect.line.ConfigHoughFootSubimage)2 ConfigLineRansac (boofcv.factory.feature.detect.line.ConfigLineRansac)2 Random (java.util.Random)1