use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class DetectCalibrationCircleHexagonalApp method renderGrid.
@Override
protected void renderGrid(Graphics2D g2, double scale) {
List<Grid> grids = detector.getDetector().getGrider().getGrids().toList();
BasicStroke thin = new BasicStroke(3);
BasicStroke thick = new BasicStroke(5);
for (Grid g : grids) {
double x0 = Double.MAX_VALUE;
double x1 = -Double.MAX_VALUE;
double y0 = Double.MAX_VALUE;
double y1 = -Double.MAX_VALUE;
for (int i = 0; i < g.ellipses.size(); i++) {
EllipseRotated_F64 e = g.ellipses.get(i);
if (e == null)
continue;
x0 = Math.min(e.center.x, x0);
x1 = Math.max(e.center.x, x1);
y0 = Math.min(e.center.y, y0);
y1 = Math.max(e.center.y, y1);
}
x0 *= scale;
y0 *= scale;
x1 *= scale;
y1 *= scale;
g2.setColor(Color.WHITE);
g2.setStroke(thick);
VisualizeShapes.drawRectangle(x0, y0, x1, y1, line, g2);
g2.setColor(Color.ORANGE);
g2.setStroke(thin);
VisualizeShapes.drawRectangle(x0, y0, x1, y1, line, g2);
}
renderTangents(g2, scale);
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class DetectCalibrationCircleRegularApp method renderGrid.
@Override
protected void renderGrid(Graphics2D g2, double scale) {
List<Grid> grids = detector.getDetector().getGrider().getGrids().toList();
BasicStroke thin = new BasicStroke(3);
BasicStroke thick = new BasicStroke(5);
for (Grid g : grids) {
double x0 = Double.MAX_VALUE;
double x1 = -Double.MAX_VALUE;
double y0 = Double.MAX_VALUE;
double y1 = -Double.MAX_VALUE;
for (int i = 0; i < g.ellipses.size(); i++) {
EllipseRotated_F64 e = g.ellipses.get(i);
if (e == null)
continue;
x0 = Math.min(e.center.x, x0);
x1 = Math.max(e.center.x, x1);
y0 = Math.min(e.center.y, y0);
y1 = Math.max(e.center.y, y1);
}
x0 *= scale;
y0 *= scale;
x1 *= scale;
y1 *= scale;
g2.setColor(Color.WHITE);
g2.setStroke(thick);
VisualizeShapes.drawRectangle(x0, y0, x1, y1, line, g2);
g2.setColor(Color.ORANGE);
g2.setStroke(thin);
VisualizeShapes.drawRectangle(x0, y0, x1, y1, line, g2);
}
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class DetectCircleGrid method process.
/**
* Processes the image and finds grids. To retrieve the found grids call {@link #getGrids()}
* @param gray Input image
*/
public void process(T gray) {
if (verbose)
System.out.println("ENTER DetectCircleGrid.process()");
configureContourDetector(gray);
this.binary.reshape(gray.width, gray.height);
inputToBinary.process(gray, binary);
ellipseDetector.process(gray, binary);
List<BinaryEllipseDetector.EllipseInfo> found = ellipseDetector.getFound().toList();
if (verbose)
System.out.println(" Found " + found.size() + " ellpises");
clusters.clear();
clustering.process(found, clusters);
clustersPruned.clear();
clustersPruned.addAll(clusters);
if (verbose)
System.out.println(" Found " + clusters.size() + " clusters");
pruneIncorrectSize(clustersPruned, totalEllipses(numRows, numCols));
if (verbose)
System.out.println(" Remaining clusters after pruning by size " + clustersPruned.size());
List<EllipseRotated_F64> foundEllipses = new ArrayList<>();
for (int i = 0; i < found.size(); i++) {
foundEllipses.add(found.get(i).ellipse);
}
grider.process(foundEllipses, clustersPruned);
FastQueue<Grid> grids = grider.getGrids();
if (verbose)
System.out.println(" Found " + grids.size() + " grids");
pruneIncorrectShape(grids, numRows, numCols);
if (verbose)
System.out.println(" Remaining grids after pruning by shape " + grids.size());
validGrids.clear();
for (int i = 0; i < grids.size(); i++) {
Grid g = grids.get(i);
putGridIntoCanonical(g);
validGrids.add(g);
}
if (verbose)
System.out.println("EXIT DetectCircleGrid.process()");
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestDetectCircleGrid method rotateGridCCW.
@Test
public void rotateGridCCW() {
Grid g = createGrid(3, 3);
List<EllipseRotated_F64> original = new ArrayList<>();
original.addAll(g.ellipses);
DetectCircleGrid<?> alg = new HelperAlg(3, 3);
alg.rotateGridCCW(g);
assertEquals(9, g.ellipses.size());
assertTrue(original.get(6) == g.get(0, 0));
assertTrue(original.get(0) == g.get(0, 2));
assertTrue(original.get(2) == g.get(2, 2));
assertTrue(original.get(8) == g.get(2, 0));
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestDetectCircleGrid method flipVertical.
static Grid flipVertical(Grid g) {
Grid out = new Grid();
for (int i = 0; i < g.rows; i++) {
for (int j = 0; j < g.columns; j++) {
out.ellipses.add(g.get(g.rows - i - 1, j));
}
}
out.columns = g.columns;
out.rows = g.rows;
return out;
}
Aggregations