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);
}
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;
}
}
}
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);
}
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");
}
Aggregations