use of boofcv.alg.fiducial.calib.squares.SquareNode in project BoofCV by lessthanoptimal.
the class CommonDetectCalibrationApp method renderGraph.
protected void renderGraph(Graphics2D g2, double scale) {
List<List<SquareNode>> graphs = getClusters();
BasicStroke strokeWide = new BasicStroke(3);
BasicStroke strokeNarrow = new BasicStroke(2);
Line2D.Double l = new Line2D.Double();
g2.setStroke(new BasicStroke(3));
for (int i = 0; i < graphs.size(); i++) {
List<SquareNode> graph = graphs.get(i);
int key = graphs.size() == 1 ? 0 : 255 * i / (graphs.size() - 1);
int rgb = key << 8 | (255 - key);
g2.setColor(new Color(rgb));
List<SquareEdge> edges = new ArrayList<>();
for (SquareNode n : graph) {
for (int j = 0; j < n.edges.length; j++) {
if (n.edges[j] != null && !edges.contains(n.edges[j])) {
edges.add(n.edges[j]);
}
}
}
for (SquareEdge e : edges) {
Point2D_F64 a = e.a.center;
Point2D_F64 b = e.b.center;
l.setLine(a.x * scale, a.y * scale, b.x * scale, b.y * scale);
g2.setColor(Color.CYAN);
g2.setStroke(strokeWide);
g2.draw(l);
g2.setColor(new Color(rgb));
g2.setStroke(strokeNarrow);
g2.draw(l);
}
}
}
use of boofcv.alg.fiducial.calib.squares.SquareNode in project BoofCV by lessthanoptimal.
the class TestDetectChessboardSquarePoints method createGrid.
public static SquareGrid createGrid(int rows, int cols) {
SquareGrid grid = new SquareGrid();
grid.columns = cols;
grid.rows = rows;
double w = TestSquareRegularClustersIntoGrids.DEFAULT_WIDTH;
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
if (row % 2 == 0) {
if (col % 2 == 0) {
grid.nodes.add(createSquare(col * w, row * w, w));
} else {
grid.nodes.add(null);
}
} else {
if (col % 2 == 0) {
grid.nodes.add(null);
} else {
grid.nodes.add(createSquare(col * w, row * w, w));
}
}
}
}
for (int row = 0; row < rows - 1; row++) {
for (int col = 0; col < cols; col++) {
SquareNode n = grid.get(row, col);
if (n == null)
continue;
if (col > 0) {
SquareNode a = grid.get(row + 1, col - 1);
connect(n, 3, a, 1);
}
if (col < cols - 1) {
SquareNode a = grid.get(row + 1, col + 1);
connect(n, 2, a, 0);
}
}
}
return grid;
}
use of boofcv.alg.fiducial.calib.squares.SquareNode 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 boofcv.alg.fiducial.calib.squares.SquareNode in project BoofCV by lessthanoptimal.
the class TestQrCodePositionPatternDetector method considerConnect_positive.
/**
* Simple positive example
*/
@Test
public void considerConnect_positive() {
QrCodePositionPatternDetector<GrayF32> alg = createAlg();
SquareNode n0 = squareNode(40, 60, 70);
SquareNode n1 = squareNode(140, 60, 70);
alg.considerConnect(n0, n1);
assertEquals(1, n0.getNumberOfConnections());
assertEquals(1, n1.getNumberOfConnections());
}
use of boofcv.alg.fiducial.calib.squares.SquareNode in project BoofCV by lessthanoptimal.
the class TestQrCodePositionPatternDetector method considerConnect_negative_rotated.
/**
* The two patterns are rotated 45 degrees relative to each other
*/
@Test
public void considerConnect_negative_rotated() {
QrCodePositionPatternDetector<GrayF32> alg = createAlg();
SquareNode n0 = squareNode(40, 60, 70);
SquareNode n1 = squareNode(140, 60, 70);
Se2_F64 translate = new Se2_F64(-175, -95, 0);
Se2_F64 rotate = new Se2_F64(0, 0, UtilAngle.radian(45));
Se2_F64 tmp = translate.concat(rotate, null);
Se2_F64 combined = tmp.concat(translate.invert(null), null);
for (int i = 0; i < 4; i++) {
SePointOps_F64.transform(combined, n1.square.get(i), n1.square.get(i));
}
SePointOps_F64.transform(combined, n1.center, n1.center);
alg.considerConnect(n0, n1);
assertEquals(0, n0.getNumberOfConnections());
assertEquals(0, n1.getNumberOfConnections());
}
Aggregations