use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToGrayLine method fit_perfect_affine.
public void fit_perfect_affine(boolean black, Affine2D_F64 affine, Class imageType) {
this.transform.set(affine);
renderDistortedRectangles(black, imageType);
RefinePolygonToGrayLine alg = createAlg(4, imageType);
Polygon2D_F64 input = createFromSquare(affine);
Polygon2D_F64 expected = input.copy();
Polygon2D_F64 found = new Polygon2D_F64(4);
alg.setImage(image);
assertTrue(alg.refine(input, found));
// input shouldn't be modified
assertTrue(expected.isIdentical(input, 0));
// should be close to the expected
assertTrue(expected.isIdentical(found, 0.27));
// do it again with a sub-image to see if it handles that
image = BoofTesting.createSubImageOf_S(image);
alg.setImage(image);
assertTrue(alg.refine(input, found));
assertTrue(expected.isIdentical(input, 0));
assertTrue(expected.isIdentical(found, 0.27));
}
use of georegression.struct.shapes.Polygon2D_F64 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.Polygon2D_F64 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.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestEdgeIntensityPolygon method computeEdge.
@Test
public void computeEdge() {
GrayU8 image = new GrayU8(400, 500);
int value = 200;
ImageMiscOps.fillRectangle(image, value, 20, 30, 40, 40);
EdgeIntensityPolygon<GrayU8> alg = new EdgeIntensityPolygon<>(2, 2, 10, GrayU8.class);
Polygon2D_F64 polygon = new Polygon2D_F64(4);
UtilPolygons2D_F64.convert(new Rectangle2D_F64(20, 30, 60, 70), polygon);
alg.setImage(image);
assertTrue(alg.computeEdge(polygon, polygon.isCCW()));
// should be average pixel intensity inside and outside
assertEquals(200, alg.getAverageInside(), 1e-8);
assertEquals(0, alg.getAverageOutside(), 1e-8);
// see what happens if the incorrect orientation is passed in
assertTrue(alg.computeEdge(polygon, !polygon.isCCW()));
assertEquals(0, alg.getAverageInside(), 1e-8);
assertEquals(200, alg.getAverageOutside(), 1e-8);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class DetectSquareGridFiducial method extractCalibrationPoints.
/**
* Extracts the calibration points from the corners of a fully ordered grid
*/
void extractCalibrationPoints(SquareGrid grid) {
calibrationPoints.clear();
for (int row = 0; row < grid.rows; row++) {
row0.clear();
row1.clear();
for (int col = 0; col < grid.columns; col++) {
Polygon2D_F64 square = grid.get(row, col).square;
row0.add(square.get(0));
row0.add(square.get(1));
row1.add(square.get(3));
row1.add(square.get(2));
}
calibrationPoints.addAll(row0);
calibrationPoints.addAll(row1);
}
// calibCols = grid.columns*2;
// calibRows = grid.rows*2;
}
Aggregations