use of boofcv.factory.shape.ConfigPolygonDetector in project BoofCV by lessthanoptimal.
the class TestDetectChessboardSquarePoints method basicTest.
public void basicTest(int rows, int cols) {
// System.out.println("grid shape rows = "+ rows +" cols = "+ cols);
GrayU8 binary = createTarget(rows, cols);
GrayU8 gray = binary.clone();
PixelMath.multiply(gray, 200, gray);
PixelMath.minus(255, gray, gray);
// ShowImages.showWindow(gray,"Input");
// try {
// Thread.sleep(2000);
// } catch (InterruptedException ignore) {}
DetectPolygonBinaryGrayRefine<GrayU8> detectorSquare = FactoryShapeDetector.polygon(new ConfigPolygonDetector(4, 4), GrayU8.class);
DetectChessboardSquarePoints<GrayU8> alg = new DetectChessboardSquarePoints<>(rows, cols, ConfigLength.fixed(2), detectorSquare);
// System.out.println("test grid "+ gridWidth + " " + gridHeight);
assertTrue(alg.process(gray, binary));
List<Point2D_F64> calib = alg.getCalibrationPoints().toList();
double x0 = offsetX + squareLength;
double y0 = offsetY + squareLength;
int pointRows = 2 * (rows / 2) - 1 + rows % 2;
int pointCols = 2 * (cols / 2) - 1 + cols % 2;
assertEquals(pointCols * pointRows, calib.size());
int index = 0;
for (int row = 0; row < pointRows; row++) {
for (int col = 0; col < pointCols; col++) {
assertTrue(calib.get(index++).distance(x0 + col * squareLength, y0 + row * squareLength) < 3);
}
}
}
use of boofcv.factory.shape.ConfigPolygonDetector in project BoofCV by lessthanoptimal.
the class TestDetectChessboardSquarePoints method touchImageEdge.
/**
* Crash case. The outer grid touches the image edge but not the inner.
*/
@Test
public void touchImageEdge() {
offsetX = -10;
offsetY = -15;
int gridWidth = 4;
int gridHeight = 5;
GrayU8 binary = createTarget(gridHeight, gridWidth);
GrayU8 gray = binary.clone();
PixelMath.multiply(gray, 200, gray);
PixelMath.minus(255, gray, gray);
// ShowImages.showWindow(gray, "Input");
// try {
// Thread.sleep(2000);
// } catch (InterruptedException ignore) {}
DetectPolygonBinaryGrayRefine<GrayU8> detectorSquare = FactoryShapeDetector.polygon(new ConfigPolygonDetector(4, 4), GrayU8.class);
DetectChessboardSquarePoints<GrayU8> alg = new DetectChessboardSquarePoints<>(gridWidth, gridHeight, ConfigLength.fixed(2), detectorSquare);
assertFalse(alg.process(gray, binary));
}
use of boofcv.factory.shape.ConfigPolygonDetector in project BoofCV by lessthanoptimal.
the class TestQrCodePositionPatternDetector method createAlg.
private QrCodePositionPatternDetector<GrayF32> createAlg() {
ConfigPolygonDetector config = new ConfigPolygonDetector(4, 4);
config.detector.clockwise = false;
DetectPolygonBinaryGrayRefine<GrayF32> squareDetector = FactoryShapeDetector.polygon(config, GrayF32.class);
return new QrCodePositionPatternDetector<>(squareDetector, 2);
}
use of boofcv.factory.shape.ConfigPolygonDetector in project BoofCV by lessthanoptimal.
the class DetectBlackPolygonApp method getConfigPolygonDetector.
public ConfigPolygonDetector getConfigPolygonDetector() {
DetectBlackPolygonAppControlPanel controls = (DetectBlackPolygonAppControlPanel) DetectBlackPolygonApp.this.controls;
ConfigPolygonDetector config = controls.polygonPanel.getConfigPolygon();
return config;
}
use of boofcv.factory.shape.ConfigPolygonDetector in project BoofCV by lessthanoptimal.
the class ExampleDetectBlackPolygon method main.
public static void main(String[] args) {
String[] imagesConvex = new String[] { "shapes/polygons01.jpg", "shapes/shapes02.png", "fiducial/image/examples/image01.jpg" };
String[] imagesConcave = new String[] { "shapes/concave01.jpg" };
ListDisplayPanel panel = new ListDisplayPanel();
// first configure the detector to only detect convex shapes with 3 to 7 sides
ConfigPolygonDetector config = new ConfigPolygonDetector(3, 7);
DetectPolygonBinaryGrayRefine<GrayU8> detector = FactoryShapeDetector.polygon(config, GrayU8.class);
processImages(imagesConvex, detector, panel);
// now lets detect concave shapes with many sides
config.detector.contourToPoly.maximumSides = 12;
config.detector.contourToPoly.convex = false;
detector = FactoryShapeDetector.polygon(config, GrayU8.class);
processImages(imagesConcave, detector, panel);
ShowImages.showWindow(panel, "Found Polygons", true);
}
Aggregations