use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestDetectChessboardSquarePoints method adjustBeforeOptimize_touchesBorder.
@Test
public void adjustBeforeOptimize_touchesBorder() {
DetectChessboardSquarePoints<GrayU8> alg = new DetectChessboardSquarePoints<>(2, 2, ConfigLength.fixed(0.01), null);
GrowQueue_B touches = new GrowQueue_B();
touches.add(true);
touches.add(true);
touches.add(false);
touches.add(true);
for (boolean clockwise : new boolean[] { true, false }) {
Polygon2D_F64 polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
if (clockwise)
polygon.flip();
alg.adjustBeforeOptimize(polygon, touches, clockwise);
int[] table = clockwise ? new int[] { 0, 3, 2, 1 } : new int[] { 0, 1, 2, 3 };
assertEquals(10, polygon.get(table[0]).x, UtilEjml.TEST_F64);
assertEquals(12, polygon.get(table[0]).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(table[1]).x, UtilEjml.TEST_F64);
assertEquals(12, polygon.get(table[1]).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(table[2]).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(table[2]).y, UtilEjml.TEST_F64);
assertEquals(10, polygon.get(table[3]).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(table[3]).y, UtilEjml.TEST_F64);
}
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestDetectChessboardSquarePoints method adjustBeforeOptimize.
@Test
public void adjustBeforeOptimize() {
DetectChessboardSquarePoints<GrayU8> alg = new DetectChessboardSquarePoints<>(2, 2, ConfigLength.fixed(0.01), null);
Polygon2D_F64 polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
alg.adjustBeforeOptimize(polygon, new GrowQueue_B(), false);
assertEquals(8.5, polygon.get(0).x, UtilEjml.TEST_F64);
assertEquals(10.5, polygon.get(0).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(1).x, UtilEjml.TEST_F64);
assertEquals(10.5, polygon.get(1).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(2).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(2).y, UtilEjml.TEST_F64);
assertEquals(8.5, polygon.get(3).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(3).y, UtilEjml.TEST_F64);
polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
polygon.flip();
alg.adjustBeforeOptimize(polygon, new GrowQueue_B(), true);
assertEquals(8.5, polygon.get(0).x, UtilEjml.TEST_F64);
assertEquals(10.5, polygon.get(0).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(3).x, UtilEjml.TEST_F64);
assertEquals(10.5, polygon.get(3).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(2).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(2).y, UtilEjml.TEST_F64);
assertEquals(8.5, polygon.get(1).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(1).y, UtilEjml.TEST_F64);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestQrCodePositionPatternDetector method squareNode.
public static SquareNode squareNode(int x0, int y0, int width) {
Polygon2D_F64 square = square(x0, y0, width);
SquareNode node = new SquareNode();
node.square = square;
node.largestSide = width;
node.smallestSide = width;
node.center.set(x0 + width / 2, y0 + width / 2);
for (int i = 0; i < 4; i++) {
node.sideLengths[i] = width;
}
return node;
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestQrCodePositionPatternDetector method square.
public static Polygon2D_F64 square(int x0, int y0, int width) {
Polygon2D_F64 square = new Polygon2D_F64(4);
square.get(0).set(x0, y0);
square.get(1).set(x0 + width, y0);
square.get(2).set(x0 + width, y0 + width);
square.get(3).set(x0, y0 + width);
return square;
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestSquareCrossClustersIntoGrids method createCluster.
/**
* Creates a new two row graph. Skip indicates if the first row skips the first column or not. The
* other two parameters specify how many nodes in each row
*/
private List<SquareNode> createCluster(boolean skip, int... levels) {
int total = 0;
for (int i = 0; i < levels.length; i++) {
total += levels[i];
}
List<SquareNode> out = new ArrayList<>();
for (int i = 0; i < total; i++) {
out.add(new SquareNode());
out.get(i).graph = SquareNode.RESET_GRAPH;
out.get(i).square = new Polygon2D_F64(4);
}
int previous = 0;
for (int i = 0; i < levels.length - 1; i++) {
int current = previous + levels[i];
int next = current + levels[i + 1];
for (int a = 0; a < levels[i]; a++) {
SquareNode n = out.get(previous + a);
int right = skip ? current + a + 1 : current + a;
int left = right - 1;
if (right < next)
connect(n, 2, out.get(right), 0);
if (left >= current) {
connect(n, 3, out.get(left), 1);
}
}
previous = current;
skip = !skip;
}
return out;
}
Aggregations