use of georegression.struct.shapes.Rectangle2D_I32 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToGrayLine method fit_noisy_affine.
/**
* Fit the quad with a noisy initial guess
*/
@Test
public void fit_noisy_affine() {
// distorted and undistorted views
Affine2D_F64[] affines = new Affine2D_F64[2];
affines[0] = new Affine2D_F64();
affines[1] = new Affine2D_F64(1.3, 0.05, -0.15, 0.87, 0.1, 0.6);
ConvertTransform_F64.convert(new Se2_F64(0, 0, 0.2), affines[0]);
rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
for (Class imageType : imageTypes) {
for (Affine2D_F64 a : affines) {
// System.out.println(imageType+" "+a);
fit_noisy_affine(true, a, imageType);
fit_noisy_affine(false, a, imageType);
}
}
}
use of georegression.struct.shapes.Rectangle2D_I32 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToGrayLine method fit_tooSmall.
/**
* Give it a shape which is too small and see if it fails
*/
@Test
public void fit_tooSmall() {
final boolean black = true;
Polygon2D_F64 input = new Polygon2D_F64(5, 5, 5, 6, 6, 6, 6, 5);
rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
for (Class imageType : imageTypes) {
renderDistortedRectangles(black, imageType);
RefinePolygonToGrayLine alg = createAlg(input.size(), imageType);
Polygon2D_F64 output = new Polygon2D_F64(input.size());
alg.setImage(image);
assertFalse(alg.refine(input, output));
}
}
use of georegression.struct.shapes.Rectangle2D_I32 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToGrayLine method fit_perfect_affine.
/**
* Perfect initial guess.
*/
@Test
public void fit_perfect_affine() {
// distorted and undistorted views
Affine2D_F64[] affines = new Affine2D_F64[2];
affines[0] = new Affine2D_F64();
affines[1] = new Affine2D_F64(1.3, 0.05, -0.15, 0.87, 0.1, 0.6);
ConvertTransform_F64.convert(new Se2_F64(0, 0, 0.2), affines[0]);
rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
for (Class imageType : imageTypes) {
for (Affine2D_F64 a : affines) {
// System.out.println(imageType+" "+a);
fit_perfect_affine(true, a, imageType);
fit_perfect_affine(false, a, imageType);
}
}
}
use of georegression.struct.shapes.Rectangle2D_I32 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToGrayLine method fit_subimage.
/**
* Makes sure it can handle sub-images
*/
@Test
public void fit_subimage() {
final boolean black = true;
rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
Polygon2D_F64 input = new Polygon2D_F64(x0, y0, x0, y1, x1, y1, x1, y0);
for (Class imageType : imageTypes) {
renderDistortedRectangles(black, imageType);
RefinePolygonToGrayLine alg = createAlg(input.size(), imageType);
Polygon2D_F64 output = new Polygon2D_F64(4);
alg.setImage(image);
assertTrue(alg.refine(input, output));
// do it again with a sub-image
Polygon2D_F64 output2 = new Polygon2D_F64(4);
image = BoofTesting.createSubImageOf_S(image);
alg.setImage(image);
assertTrue(alg.refine(input, output2));
assertTrue(UtilPolygons2D_F64.isIdentical(output, output2, 1e-8));
}
}
use of georegression.struct.shapes.Rectangle2D_I32 in project narchy by automenta.
the class ShapeSensor method inputQuadBlob.
private void inputQuadBlob(int k, List<PointIndex_I32> polygon, float w, float h) {
Polygon2D_I32 p = new Polygon2D_I32(polygon.size());
for (PointIndex_I32 v : polygon) p.vertexes.add(v);
Rectangle2D_I32 quad = new Rectangle2D_I32();
UtilPolygons2D_I32.bounding(p, quad);
float cx = ((quad.x0 + quad.x1) / 2f) / w;
float cy = ((quad.y0 + quad.y1) / 2f) / h;
float cw = quad.getWidth() / w;
float ch = quad.getHeight() / h;
Term pid = $.p(id, $.the(k));
float conf = nar.confDefault(BELIEF);
long now = nar.time();
believe(now, $.inh(pid, $.the("x")), $.t(cx, conf));
believe(now, $.inh(pid, $.the("y")), $.t(cy, conf));
believe(now, $.inh(pid, $.the("w")), $.t(cw, conf));
believe(now, $.inh(pid, $.the("h")), $.t(ch, conf));
}
Aggregations