use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestEllipseClustersIntoHexagonalGrid method createHexagonalGrid.
private Tuple2<List<Node>, List<EllipseRotated_F64>> createHexagonalGrid(int rows, int cols, double diameter, double distance) {
List<EllipseRotated_F64> ellipses = new ArrayList<>();
double spaceX = distance / 2.0;
double spaceY = spaceX * hexY;
double r = diameter / 2.0;
for (int row = 0; row < rows; row++) {
double y = row * spaceY;
for (int col = row % 2; col < cols; col += 2) {
double x = col * spaceX;
ellipses.add(new EllipseRotated_F64(x, y, r, r, 0));
}
}
return connectEllipses(ellipses, distance * 2);
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class DetectCalibrationCircleHexagonalApp method drawGraph.
private void drawGraph(Graphics2D g2, Grid g, int row0, int col0, double scale) {
for (int row = row0; row < g.rows; row += 2) {
for (int col = col0; col < g.columns; col += 2) {
EllipseRotated_F64 a = g.get(row, col);
line.x1 = scale * a.center.x;
line.y1 = scale * a.center.y;
if (col + 2 < g.columns) {
EllipseRotated_F64 b = g.get(row, col + 2);
line.x2 = scale * b.center.x;
line.y2 = scale * b.center.y;
g2.draw(line);
}
if (row + 2 < g.rows) {
EllipseRotated_F64 b = g.get(row + 2, col);
line.x2 = scale * b.center.x;
line.y2 = scale * b.center.y;
g2.draw(line);
}
}
}
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestBinaryEllipseDetector method filterByEdge.
/**
* Handle a situation where a shape should be filtered out based on its edge intensity
*/
@Test
public void filterByEdge() {
List<EllipseRotated_F64> expected = new ArrayList<>();
expected.add(new EllipseRotated_F64(50, 65, 20, 10, 0.5));
GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 210, expected, 0);
GrayU8 binary = image.createSameShape();
ThresholdImageOps.threshold(image, binary, 30, true);
BinaryEllipseDetector<GrayU8> alg = create();
// pass once with it being a clear edge
alg.process(image, binary);
List<EllipseRotated_F64> found = alg.getFoundEllipses(null);
TestBinaryEllipseDetectorPixel.checkEquals_F64(expected, found, 1.0, 0.1);
// now make the ellipse more dim so it shouldn't pass
image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 210, expected, 255 - THRESHOLD + 5);
alg.process(image, binary);
assertEquals(0, alg.getFound().size());
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestBinaryEllipseDetector method simpleCase.
/**
* Simple test case with unambiguous detections
*/
@Test
public void simpleCase() {
List<EllipseRotated_F64> expected = new ArrayList<>();
expected.add(new EllipseRotated_F64(50, 65, 20, 10, 0.5));
expected.add(new EllipseRotated_F64(90, 100, 25, 25, 0));
GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 210, expected, 0);
GrayU8 binary = image.createSameShape();
ThresholdImageOps.threshold(image, binary, 30, true);
BinaryEllipseDetector<GrayU8> alg = create();
alg.process(image, binary);
List<EllipseRotated_F64> found = alg.getFoundEllipses(null);
TestBinaryEllipseDetectorPixel.checkEquals_F64(expected, found, 1.0, 0.1);
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestBinaryEllipseDetectorPixel method isApproximatelyElliptical_large.
/**
* Test to see if it is approximately elliptical when the number of pixels is larger
* than the threshold
*/
@Test
public void isApproximatelyElliptical_large() {
EllipseRotated_F64 ellipse = new EllipseRotated_F64(5, 3, 10, 6, 0);
List<Point2D_F64> negative = TestShapeFittingOps.createRectangle_F64(20, 10, 60 - 4);
List<Point2D_F64> positive = TestShapeFittingOps.createEllipse_F64(ellipse, 60 - 4);
BinaryEllipseDetectorPixel alg = new BinaryEllipseDetectorPixel();
alg.setMaxDistanceFromEllipse(1.5);
assertFalse(alg.isApproximatelyElliptical(ellipse, negative, 20));
assertTrue(alg.isApproximatelyElliptical(ellipse, positive, 20));
}
Aggregations