use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestBinaryEllipseDetectorPixel method checkEquals_F64.
public static void checkEquals_F64(List<EllipseRotated_F64> expected, List<EllipseRotated_F64> found, double tol, double tolPhi) {
assertEquals(expected.size(), found.size());
boolean[] matched = new boolean[expected.size()];
for (EllipseRotated_F64 f : found) {
boolean foundMatch = false;
for (int i = 0; i < expected.size(); i++) {
EllipseRotated_F64 e = expected.get(i);
if (Math.abs(f.a - e.a) <= tol && Math.abs(f.b - e.b) <= tol) {
boolean angleMatch = true;
// if it's a circle ignore the angle
if (Math.abs(e.a - e.b) / Math.max(e.a, e.b) > 0.01) {
angleMatch = UtilAngle.distHalf(f.phi, e.phi) <= tolPhi;
}
if (angleMatch && e.center.distance(f.center) <= tol) {
foundMatch = matched[i] = true;
}
}
}
if (!foundMatch) {
System.out.println("Found");
System.out.println(f);
System.out.println("\nExpected");
for (int i = 0; i < expected.size(); i++) {
System.out.println(expected.get(i));
}
}
assertTrue(foundMatch);
}
for (int i = 0; i < matched.length; i++) {
assertTrue(matched[i]);
}
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestEdgeIntensityEllipse method check.
/**
* Basic check to see if the score is higher when dead on.
*/
private void check(EllipseRotated_F64 ellipse) {
List<EllipseRotated_F64> list = new ArrayList<>();
list.add(ellipse);
GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 210, list, 0);
EdgeIntensityEllipse<GrayU8> alg = new EdgeIntensityEllipse<>(1.5, 20, 10.0, GrayU8.class);
alg.setImage(image);
assertTrue(alg.process(ellipse));
double score0 = alg.getEdgeIntensity();
// now try it again with it offset a little. score should go down
ellipse.center.x += 0.75;
assertTrue(alg.process(ellipse));
double score1 = alg.getEdgeIntensity();
assertTrue(score1 < score0);
assertTrue(score0 >= 0 && score0 <= 255);
assertTrue(score1 >= 0 && score1 <= 255);
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestSnapToEllipseEdge method simpleNoChange_border.
/**
* The ellipse touches the image border
*/
@Test
public void simpleNoChange_border() {
EllipseRotated_F64 target = new EllipseRotated_F64(35, 85, 50, 40, 0);
EllipseRotated_F64 found = new EllipseRotated_F64();
List<EllipseRotated_F64> ellipses = new ArrayList<>();
ellipses.add(target);
GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 300, ellipses, 0);
SnapToEllipseEdge<GrayU8> alg = new SnapToEllipseEdge<>(30, 1, GrayU8.class);
alg.setImage(image);
assertTrue(alg.process(target, found));
TestBinaryEllipseDetectorPixel.checkEquals(target, found, 1.0, 0.01);
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestSnapToEllipseEdge method simpleNoChange.
/**
* Simple test case involving a fully rendered image and known result
*/
@Test
public void simpleNoChange() {
EllipseRotated_F64 target = new EllipseRotated_F64(80, 85, 50, 40, 0);
EllipseRotated_F64 found = new EllipseRotated_F64();
List<EllipseRotated_F64> ellipses = new ArrayList<>();
ellipses.add(target);
GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 300, ellipses, 0);
SnapToEllipseEdge<GrayU8> alg = new SnapToEllipseEdge<>(30, 1, GrayU8.class);
alg.setImage(image);
assertTrue(alg.process(target, found));
TestBinaryEllipseDetectorPixel.checkEquals(target, found, 1.0, 0.01);
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestShapeFittingOps method fitEllipse_F64.
/**
* Check the found solution
*/
@Test
public void fitEllipse_F64() {
EllipseRotated_F64 rotated = new EllipseRotated_F64(1, 2, 3, 2, -0.05);
List<Point2D_F64> points = new ArrayList<>();
for (int i = 0; i < 20; i++) {
double theta = 2.0 * (double) Math.PI * i / 20;
points.add(UtilEllipse_F64.computePoint(theta, rotated, null));
}
EllipseRotated_F64 found = ShapeFittingOps.fitEllipse_F64(points, 0, false, null).shape;
assertEquals(rotated.center.x, found.center.x, 1e-8);
assertEquals(rotated.center.y, found.center.y, 1e-8);
assertEquals(rotated.a, found.a, 1e-8);
assertEquals(rotated.b, found.b, 1e-8);
assertEquals(rotated.phi, found.phi, 1e-8);
// make sure refinement doesn't skew it up
found = ShapeFittingOps.fitEllipse_F64(points, 20, false, null).shape;
assertEquals(rotated.center.x, found.center.x, 1e-8);
assertEquals(rotated.center.y, found.center.y, 1e-8);
assertEquals(rotated.a, found.a, 1e-8);
assertEquals(rotated.b, found.b, 1e-8);
assertEquals(rotated.phi, found.phi, 1e-8);
}
Aggregations