use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestDetectCircleGrid method closestCorner4.
@Test
public void closestCorner4() {
Grid g = new Grid();
g.rows = 3;
g.columns = 3;
g.ellipses.add(new EllipseRotated_F64(20, 20, 0, 0, 0));
g.ellipses.add(null);
g.ellipses.add(new EllipseRotated_F64(20, 100, 0, 0, 0));
g.ellipses.add(null);
g.ellipses.add(new EllipseRotated_F64());
g.ellipses.add(null);
g.ellipses.add(new EllipseRotated_F64(100, 20, 0, 0, 0));
g.ellipses.add(null);
g.ellipses.add(new EllipseRotated_F64(100, 100, 0, 0, 0));
assertEquals(0, DetectCircleGrid.closestCorner4(g));
g.ellipses.get(0).center.set(20, 100);
g.ellipses.get(2).center.set(100, 20);
g.ellipses.get(6).center.set(100, 100);
g.ellipses.get(8).center.set(20, 20);
assertEquals(2, DetectCircleGrid.closestCorner4(g));
g.ellipses.get(0).center.set(100, 20);
g.ellipses.get(2).center.set(100, 100);
g.ellipses.get(6).center.set(20, 20);
g.ellipses.get(8).center.set(20, 100);
assertEquals(1, DetectCircleGrid.closestCorner4(g));
g.ellipses.get(0).center.set(100, 100);
g.ellipses.get(2).center.set(20, 20);
g.ellipses.get(6).center.set(20, 100);
g.ellipses.get(8).center.set(100, 20);
assertEquals(3, DetectCircleGrid.closestCorner4(g));
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestDetectCircleHexagonalGrid method checkCounterClockWise.
static void checkCounterClockWise(Grid g) {
EllipseRotated_F64 a = g.get(0, 0);
EllipseRotated_F64 b = g.columns >= 3 ? g.get(0, 2) : g.get(1, 1);
EllipseRotated_F64 c = g.rows >= 3 ? g.get(2, 0) : g.get(1, 1);
double dx0 = b.center.x - a.center.x;
double dy0 = b.center.y - a.center.y;
double dx1 = c.center.x - a.center.x;
double dy1 = c.center.y - a.center.y;
Vector3D_F64 v = new Vector3D_F64();
GeometryMath_F64.cross(dx0, dy0, 0, dx1, dy1, 0, v);
assertTrue(v.z > 0);
}
use of georegression.struct.curve.EllipseRotated_F64 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 georegression.struct.curve.EllipseRotated_F64 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 georegression.struct.curve.EllipseRotated_F64 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;
}
Aggregations