use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestDetectCircleGrid method flipHorizontal.
static Grid flipHorizontal(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(i, g.columns - j - 1));
}
}
out.columns = g.columns;
out.rows = g.rows;
return out;
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestDetectCircleHexagonalGrid method createGrid.
static Grid createGrid(int numRows, int numCols) {
Grid g = new Grid();
g.rows = numRows;
g.columns = numCols;
for (int i = 0; i < numRows; i++) {
for (int j = 0; j < numCols; j++) {
if (i % 2 == 0) {
if (j % 2 == 0)
g.ellipses.add(new EllipseRotated_F64(j * 20, i * 20, 0, 0, 0));
else
g.ellipses.add(null);
} else {
if (j % 2 == 0)
g.ellipses.add(null);
else
g.ellipses.add(new EllipseRotated_F64(j * 20, i * 20, 0, 0, 0));
}
}
}
return g;
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestDetectCircleRegularGrid method performDetectionCheck.
private void performDetectionCheck(int expectedRows, int expectedCols, int actualRows, int actualCols, Affine2D_F64 affine) {
int diameter = 40;
int centerDistances = 120;
DetectCircleRegularGrid<GrayU8> alg = createAlg(expectedRows, expectedCols, diameter, centerDistances);
// alg.setVerbose(true);
List<Point2D_F64> keypoints = new ArrayList<>();
List<Point2D_F64> centers = new ArrayList<>();
GrayU8 image = new GrayU8(500, 550);
render(actualRows, actualCols, diameter / 2.0, centerDistances, affine, keypoints, centers, image);
alg.process(image);
List<Grid> found = alg.getGrids();
if (expectedRows != actualRows || expectedCols != actualCols) {
assertEquals(0, found.size());
return;
} else {
assertEquals(1, found.size());
}
Grid g = found.get(0);
assertEquals(actualRows, g.rows);
assertEquals(actualCols, g.columns);
TestDetectCircleRegularGrid.checkCounterClockWise(g);
for (int row = 0; row < g.rows; row++) {
for (int col = 0; col < g.columns; col++) {
EllipseRotated_F64 f = g.get(row, col);
Point2D_F64 e = centers.get(row * g.columns + col);
assertEquals(e.x, f.center.x, 1.5);
assertEquals(e.y, f.center.y, 1.5);
assertEquals(20, f.a, 1.0);
assertEquals(20, f.b, 1.0);
}
}
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestDetectCircleRegularGrid method createGrid.
static Grid createGrid(int numRows, int numCols) {
Grid g = new Grid();
g.rows = numRows;
g.columns = numCols;
for (int i = 0; i < numRows; i++) {
for (int j = 0; j < numCols; j++) {
g.ellipses.add(new EllipseRotated_F64(j * 20, i * 20, 0, 0, 0));
}
}
return g;
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestEllipseClustersIntoGrid method grid_getIndexOfHexEllipse.
private void grid_getIndexOfHexEllipse(int numRows, int numCols) {
Grid g = new Grid();
g.rows = numRows;
g.columns = numCols;
int[] index = new int[g.rows * g.columns];
int totalEllipses = 0;
for (int row = 0; row < g.rows; row++) {
for (int col = 0; col < g.columns; col++) {
if (row % 2 == 0 && col % 2 == 1) {
g.ellipses.add(null);
} else if (row % 2 == 1 && col % 2 == 0) {
g.ellipses.add(null);
} else {
index[totalEllipses++] = row * g.columns + col;
g.ellipses.add(new EllipseRotated_F64());
}
}
}
for (int i = 0; i < totalEllipses; i++) {
int row = index[i] / g.columns;
int col = index[i] % g.columns;
assertEquals(row + " " + col, i, g.getIndexOfHexEllipse(row, col));
}
}
Aggregations