use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils in project BoofCV by lessthanoptimal.
the class ECoCheck_to_FiducialDetector method getControl3D.
@Override
protected List<Point2D3D> getControl3D(int which) {
Objects.requireNonNull(pixelToNorm);
ECoCheckFound found = foundIndexToFound(which);
MarkerShape marker = markerShapes.get(found.markerID);
points2D3D.resetResize(found.corners.size);
ECoCheckUtils utils = detector.getUtils();
// length of the longest side on the marker
double markerLength = Math.max(marker.getWidth(), marker.getHeight());
for (int i = 0; i < found.corners.size; i++) {
PointIndex2D_F64 corner = found.corners.get(i);
Point2D3D p23 = points2D3D.get(i);
utils.cornerToMarker3D(found.markerID, corner.index, p23.location);
pixelToNorm.compute(corner.p.x, corner.p.y, p23.observation);
// Convert the units
p23.location.scale(markerLength);
}
return points2D3D.toList();
}
use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils in project BoofCV by lessthanoptimal.
the class CalibrationDetectorMultiECoCheck method getLayout.
@Override
public List<Point2D_F64> getLayout(int markerID) {
List<Point2D_F64> layout = cacheLayouts.get(markerID);
if (layout != null)
return layout;
ECoCheckUtils utils = detector.getUtils();
ConfigECoCheckMarkers.MarkerShape shape = markers.get(markerID);
// Create a list of points that defines the layout
Point3D_F64 p = new Point3D_F64();
layout = new ArrayList<>();
int numCorners = shape.getNumCorners();
for (int cornerID = 0; cornerID < numCorners; cornerID++) {
utils.cornerToMarker3D(markerID, cornerID, shape.squareSize, p);
layout.add(cornerID, new Point2D_F64(p.x, p.y));
}
cacheLayouts.put(markerID, layout);
return layout;
}
use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils in project BoofCV by lessthanoptimal.
the class ECoCheck_to_FiducialDetector method detect.
@Override
public void detect(T input) {
detector.process(input);
// Find all the known detections
foundToDetection.reset();
for (int detectionID = 0; detectionID < detector.getFound().size; detectionID++) {
ECoCheckFound found = detector.found.get(detectionID);
if (found.markerID < 0)
continue;
foundToDetection.add(detectionID);
}
ECoCheckUtils utils = detector.getUtils();
Estimate1ofEpipolar computeHomography = FactoryMultiView.homographyTLS();
// Compute homographies for each marker
listMarkerToPixels.reset();
for (int knownIdx = 0; knownIdx < foundToDetection.size; knownIdx++) {
int detectionID = foundToDetection.get(knownIdx);
ECoCheckFound found = detector.found.get(detectionID);
int markerID = found.markerID;
// create a list of pairs from marker coordinates to pixels
pairs.resetResize(found.corners.size);
for (int i = 0; i < found.corners.size; i++) {
PointIndex2D_F64 foundCorner = found.corners.get(i);
// Get location of corner on marker in marker units
utils.cornerToMarker3D(markerID, foundCorner.index, point3);
// Observed pixel coordinate of corner
Point2D_F64 p = found.corners.get(i).p;
pairs.get(i).setTo(point3.x, point3.y, p.x, p.y);
}
// Find the homography that relates the coordinate systems
Homography2D_F64 h = listMarkerToPixels.grow();
if (!computeHomography.process(pairs.toList(), tmp)) {
// well this is unexpected. Let's just silently fail.
CommonOps_DDF3.fill(h, 0);
} else {
DConvertMatrixStruct.convert(tmp, h);
}
}
}
use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils in project BoofCV by lessthanoptimal.
the class UtilCalibrationGui method renderTargetBuffered.
public static BufferedImage renderTargetBuffered(CalibrationPatterns type, Object config, int squareWidth) {
int circle = squareWidth / 2;
if (type == CalibrationPatterns.ECOCHECK) {
ConfigECoCheckMarkers c = (ConfigECoCheckMarkers) config;
ECoCheckUtils utils = new ECoCheckUtils();
utils.codec.setErrorCorrectionLevel(c.errorCorrectionLevel);
utils.codec.setChecksumBitCount(c.checksumBits);
c.convertToGridList(utils.markers);
utils.fixate();
ConfigECoCheckMarkers.MarkerShape shape = c.markerShapes.get(0);
int markerWidth = squareWidth * (shape.numCols - 1);
int markerHeight = squareWidth * (shape.numRows - 1);
FiducialRenderEngineGraphics2D render = configureRenderGraphics2D(markerWidth, markerHeight, squareWidth / 2);
ECoCheckGenerator generator = new ECoCheckGenerator(utils);
generator.squareWidth = squareWidth;
generator.setRender(render);
generator.render(0);
return render.getImage();
} else if (type == CalibrationPatterns.HAMMING_CHESSBOARD) {
ConfigHammingChessboard c = (ConfigHammingChessboard) config;
int markerWidth = squareWidth * c.numCols;
int markerHeight = squareWidth * c.numRows;
FiducialRenderEngineGraphics2D render = configureRenderGraphics2D(markerWidth, markerHeight, squareWidth / 2);
HammingChessboardGenerator generator = new HammingChessboardGenerator(c);
generator.squareWidth = squareWidth;
generator.setRender(render);
generator.render();
return render.getImage();
} else if (type == CalibrationPatterns.HAMMING_GRID) {
ConfigHammingGrid c = (ConfigHammingGrid) config;
int markerWidth = (int) Math.round(squareWidth * c.getMarkerWidth() / c.squareSize);
int markerHeight = (int) Math.round(squareWidth * c.getMarkerHeight() / c.squareSize);
FiducialRenderEngineGraphics2D render = configureRenderGraphics2D(markerWidth, markerHeight, squareWidth / 2);
var generator = new HammingGridGenerator(c);
generator.squareWidth = squareWidth;
generator.setRender(render);
generator.render();
return render.getImage();
}
final RenderCalibrationTargetsGraphics2D renderer = new RenderCalibrationTargetsGraphics2D(20, 1);
if (type == CalibrationPatterns.CHESSBOARD) {
ConfigGridDimen c = (ConfigGridDimen) config;
renderer.chessboard(c.numRows, c.numCols, squareWidth);
} else if (type == CalibrationPatterns.SQUARE_GRID) {
ConfigGridDimen c = (ConfigGridDimen) config;
double space = squareWidth * c.shapeDistance / c.shapeSize;
renderer.squareGrid(c.numRows, c.numCols, squareWidth, space);
} else if (type == CalibrationPatterns.CIRCLE_GRID) {
ConfigGridDimen c = (ConfigGridDimen) config;
double space = circle * c.shapeDistance / c.shapeSize;
renderer.circleRegular(c.numRows, c.numCols, circle, space);
} else if (type == CalibrationPatterns.CIRCLE_HEXAGONAL) {
ConfigGridDimen c = (ConfigGridDimen) config;
double space = circle * c.shapeDistance / c.shapeSize;
renderer.circleHex(c.numRows, c.numCols, circle, space);
}
return renderer.getBuffered();
}
Aggregations