use of boofcv.abst.fiducial.calib.ConfigSquareGrid in project BoofCV by lessthanoptimal.
the class BaseCalibrationConfig method parseTarget.
protected void parseTarget(String where) throws FileNotFoundException {
Reader input = media.openFile(where);
SimpleStringNumberReader reader = new SimpleStringNumberReader('#');
if (!reader.read(input))
throw new RuntimeException("Parsing configuration failed");
if (reader.remainingTokens() < 7)
throw new RuntimeException("Not enough tokens in config file");
String type = reader.nextString();
numRadial = (int) reader.nextDouble();
includeTangential = Boolean.parseBoolean(reader.nextString());
assumeZeroSkew = Boolean.parseBoolean(reader.nextString());
int numCols = (int) reader.nextDouble();
int numRows = (int) reader.nextDouble();
double width = reader.nextDouble();
if (type.compareToIgnoreCase("square") == 0) {
double space = reader.nextDouble();
detector = FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(numRows, numCols, width, space));
} else if (type.compareToIgnoreCase("chess") == 0) {
detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(numRows, numCols, width));
} else {
throw new RuntimeException("Unknown type: " + type);
}
try {
input.close();
} catch (IOException e) {
}
}
use of boofcv.abst.fiducial.calib.ConfigSquareGrid in project BoofCV by lessthanoptimal.
the class CameraCalibration method parseSquareGrid.
protected void parseSquareGrid(int index, String[] args) {
int numRows = 0, numColumns = 0;
double square = 1, space = 1;
for (; index < args.length; index++) {
String arg = args[index];
if (!arg.startsWith("--")) {
throw new RuntimeException("Expected flags for square grid. Should start with '--'");
}
splitFlag(arg);
if (flagName.compareToIgnoreCase("Grid") == 0) {
String[] words = parameters.split(":");
if (words.length != 2)
throw new RuntimeException("Expected two values for rows and columns");
numRows = Integer.parseInt(words[0]);
numColumns = Integer.parseInt(words[1]);
} else if (flagName.compareToIgnoreCase("SquareSpace") == 0) {
String[] words = parameters.split(":");
if (words.length != 2)
throw new RuntimeException("Expected two values for square and space");
square = Double.parseDouble(words[0]);
space = Double.parseDouble(words[1]);
} else {
throw new RuntimeException("Unknown image option " + flagName);
}
}
if (numRows <= 0 || numColumns <= 0) {
throw new RuntimeException("Rows and columns must be specified and > 0");
}
if (square <= 0 || space <= 0) {
throw new RuntimeException("square and space width must be specified and > 0");
}
System.out.println("squaregrid: " + numRows + " x " + numColumns + " square/space = " + (square / space));
ConfigSquareGrid config = new ConfigSquareGrid(numRows, numColumns, square, space);
detector = FactoryFiducialCalibration.squareGrid(config);
}
use of boofcv.abst.fiducial.calib.ConfigSquareGrid in project BoofCV by lessthanoptimal.
the class CreateCalibrationTargetGui method updatePreview.
private void updatePreview() {
double paperWidth = paper.unit.convert(paper.width, units);
double paperHeight = paper.unit.convert(paper.height, units);
final RenderCalibrationTargetsGraphics2D renderer = new RenderCalibrationTargetsGraphics2D(-1, 400 / paperWidth);
renderer.setPaperSize(paperWidth, paperHeight);
if (selectedType == CalibrationTargetPanel.TargetType.CHESSBOARD) {
ConfigChessboard config = (ConfigChessboard) selectedCalib;
renderer.chessboard(config.numRows, config.numCols, config.squareWidth);
} else if (selectedType == CalibrationTargetPanel.TargetType.SQUARE_GRID) {
ConfigSquareGrid config = (ConfigSquareGrid) selectedCalib;
renderer.squareGrid(config.numRows, config.numCols, config.squareWidth, config.spaceWidth);
} else if (selectedType == CalibrationTargetPanel.TargetType.CIRCLE_GRID) {
ConfigCircleRegularGrid config = (ConfigCircleRegularGrid) selectedCalib;
renderer.circleRegular(config.numRows, config.numCols, config.circleDiameter, config.centerDistance);
} else if (selectedType == CalibrationTargetPanel.TargetType.CIRCLE_HEX) {
ConfigCircleHexagonalGrid config = (ConfigCircleHexagonalGrid) selectedCalib;
renderer.circleHex(config.numRows, config.numCols, config.circleDiameter, config.centerDistance);
}
renderingPanel.setImageUI(renderer.getBufferred());
}
use of boofcv.abst.fiducial.calib.ConfigSquareGrid in project BoofCV by lessthanoptimal.
the class FiducialDetection method parseSquareGrid.
void parseSquareGrid(int index, String[] args) {
int rows = -1, cols = -1;
double width = 1, space = -1;
for (; index < args.length; index++) {
String arg = args[index];
if (!arg.startsWith("--")) {
throw new RuntimeException("Expected flags for square grid calibration fiducial");
}
splitFlag(arg);
if (flagName.compareToIgnoreCase("Shape") == 0) {
String[] words = parameters.split(":");
if (words.length != 2)
throw new RuntimeException("Expected two for rows and columns");
rows = Integer.parseInt(words[0]);
cols = Integer.parseInt(words[1]);
} else if (flagName.compareToIgnoreCase("SquareWidth") == 0) {
width = Double.parseDouble(parameters);
} else if (flagName.compareToIgnoreCase("Space") == 0) {
space = Double.parseDouble(parameters);
} else {
throw new RuntimeException("Unknown square grid option " + flagName);
}
}
if (rows < 1 || cols < 1)
throw new RuntimeException("Must specify number of rows and columns");
if (space <= 0)
space = width;
System.out.println("square grid: rows = " + rows + " columns = " + cols + " square width " + width + " space " + space);
ConfigSquareGrid config = new ConfigSquareGrid(rows, cols, width, space);
detector = FactoryFiducial.calibSquareGrid(config, GrayU8.class);
}
use of boofcv.abst.fiducial.calib.ConfigSquareGrid in project BoofCV by lessthanoptimal.
the class CameraCalibrationGui method calibrationParametersChanged.
@Override
public void calibrationParametersChanged(CalibrationTargetPanel.TargetType type, Object _config) {
final RenderCalibrationTargetsGraphics2D renderer = new RenderCalibrationTargetsGraphics2D(20, 1);
if (type == CalibrationTargetPanel.TargetType.CHESSBOARD) {
ConfigChessboard chess = (ConfigChessboard) _config;
renderer.chessboard(chess.numRows, chess.numCols, 20);
} else if (type == CalibrationTargetPanel.TargetType.SQUARE_GRID) {
ConfigSquareGrid config = (ConfigSquareGrid) _config;
double space = 20 * config.spaceWidth / config.squareWidth;
renderer.squareGrid(config.numRows, config.numCols, 20, space);
} else if (type == CalibrationTargetPanel.TargetType.CIRCLE_GRID) {
ConfigCircleRegularGrid config = (ConfigCircleRegularGrid) _config;
double space = 10 * config.centerDistance / config.circleDiameter;
renderer.circleRegular(config.numRows, config.numCols, 10, space);
} else if (type == CalibrationTargetPanel.TargetType.CIRCLE_HEX) {
ConfigCircleHexagonalGrid config = (ConfigCircleHexagonalGrid) _config;
double space = 10 * config.centerDistance / config.circleDiameter;
renderer.circleHex(config.numRows, config.numCols, 10, space);
}
renderingPanel.setImageUI(renderer.getBufferred());
}
Aggregations