use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquaresIntoRegularClusters method computeNodeInfo.
@Test
public void computeNodeInfo() {
List<Polygon2D_F64> squares = new ArrayList<>();
squares.add(new Polygon2D_F64(-1, 1, 1, 1, 1, -1, -1, -1));
squares.add(new Polygon2D_F64(2, 1, 4, 1, 4, -1, 2, -1));
SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(2, 6, 1.35);
alg.computeNodeInfo(squares);
assertEquals(2, alg.nodes.size());
SquareNode a = alg.nodes.get(0);
SquareNode b = alg.nodes.get(1);
assertTrue(a.center.distance(new Point2D_F64(0, 0)) <= 1e-8);
assertTrue(b.center.distance(new Point2D_F64(3, 0)) <= 1e-8);
assertEquals(0, a.getNumberOfConnections());
assertEquals(0, b.getNumberOfConnections());
assertEquals(2, a.largestSide, 1e-8);
assertEquals(2, b.largestSide, 1e-8);
assertEquals(SquareNode.RESET_GRAPH, a.graph);
assertEquals(SquareNode.RESET_GRAPH, b.graph);
for (int i = 0; i < 4; i++) {
assertEquals(2, a.sideLengths[i], 1e-8);
assertEquals(2, b.sideLengths[i], 1e-8);
}
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestQrCodeDecoderImage method computeBoundingBox.
@Test
public void computeBoundingBox() {
QrCode qr = new QrCode();
qr.ppCorner = new Polygon2D_F64(0, 0, 1, 0, 1, 1, 0, 1);
qr.ppRight = new Polygon2D_F64(2, 0, 3, 0, 3, 1, 2, 1);
qr.ppDown = new Polygon2D_F64(0, 2, 1, 2, 1, 3, 0, 3);
QrCodeDecoderImage.computeBoundingBox(qr);
assertTrue(qr.bounds.get(0).distance(0, 0) < UtilEjml.TEST_F64);
assertTrue(qr.bounds.get(1).distance(3, 0) < UtilEjml.TEST_F64);
assertTrue(qr.bounds.get(2).distance(3, 3) < UtilEjml.TEST_F64);
assertTrue(qr.bounds.get(3).distance(0, 3) < UtilEjml.TEST_F64);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestQrCodeDecoderImage method setPositionPatterns.
@Test
public void setPositionPatterns() {
Polygon2D_F64 corner = new Polygon2D_F64(0, 0, 2, 0, 2, 2, 0, 2);
Polygon2D_F64 right = new Polygon2D_F64(5, 0, 7, 0, 7, 2, 5, 2);
Polygon2D_F64 bottom = new Polygon2D_F64(0, 5, 2, 5, 2, 7, 0, 7);
PositionPatternNode n_corner = new PositionPatternNode();
PositionPatternNode n_right = new PositionPatternNode();
PositionPatternNode n_bottom = new PositionPatternNode();
n_corner.square = corner;
n_right.square = right;
n_bottom.square = bottom;
connect(n_right, n_corner, 3, 1);
connect(n_bottom, n_corner, 0, 2);
QrCode qr = new QrCode();
QrCodeDecoderImage.setPositionPatterns(n_corner, 1, 2, qr);
assertTrue(qr.ppCorner.get(0).distance(0, 0) < UtilEjml.TEST_F64);
assertTrue(qr.ppRight.get(0).distance(5, 0) < UtilEjml.TEST_F64);
assertTrue(qr.ppDown.get(0).distance(0, 5) < UtilEjml.TEST_F64);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestDetectPolygonFromContour method checkDetected.
private void checkDetected(Class imageType, double tol) {
renderDistortedRectangles(true, imageType);
int numberOfSides = 4;
DetectPolygonFromContour alg = createDetector(imageType, numberOfSides, numberOfSides);
alg.process(image, binary);
FastQueue<DetectPolygonFromContour.Info> found = alg.getFound();
assertEquals(rectangles.size(), found.size);
for (int i = 0; i < found.size; i++) {
Polygon2D_F64 p = found.get(i).polygon;
assertEquals(1, findMatches(p, tol));
assertEquals(black, found.get(i).edgeInside, 4);
assertEquals(white, found.get(i).edgeOutside, white * 0.1);
}
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestDetectPolygonFromContour method rejectShapes_concave.
/**
* Configure the detector to reject concave shapes
*/
@Test
public void rejectShapes_concave() {
List<Polygon2D_F64> polygons = new ArrayList<>();
polygons.add(new Polygon2D_F64(20, 20, 80, 20, 80, 80, 40, 40, 20, 80));
for (Class imageType : imageTypes) {
renderPolygons(polygons, imageType);
DetectPolygonFromContour alg = createDetector(imageType, 5, 5);
alg.process(image, binary);
assertEquals(0, alg.getFound().size());
}
}
Aggregations