use of boofcv.abst.fiducial.calib.ConfigCircleHexagonalGrid 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.ConfigCircleHexagonalGrid in project BoofCV by lessthanoptimal.
the class CameraCalibration method parseCircle.
protected void parseCircle(int index, String[] args, boolean hexagonal) {
int numRows = 0, numColumns = 0;
double diameter = -1, centerDistance = -1;
for (; index < args.length; index++) {
String arg = args[index];
if (!arg.startsWith("--")) {
throw new RuntimeException("Expected flags for radius 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("CenterDistance") == 0) {
centerDistance = Double.parseDouble(parameters);
} else if (flagName.compareToIgnoreCase("Diameter") == 0) {
diameter = Double.parseDouble(parameters);
} 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 (diameter <= 0 || centerDistance <= 0) {
throw new RuntimeException("diameter and center distance must be specified and > 0");
}
if (hexagonal) {
System.out.println("circle hexagonal: " + numRows + " x " + numColumns + " diameter = " + diameter + " center distance = " + centerDistance);
ConfigCircleHexagonalGrid config = new ConfigCircleHexagonalGrid(numRows, numColumns, diameter, centerDistance);
detector = FactoryFiducialCalibration.circleHexagonalGrid(config);
} else {
System.out.println("circle regular: " + numRows + " x " + numColumns + " diameter = " + diameter + " center distance = " + centerDistance);
ConfigCircleRegularGrid config = new ConfigCircleRegularGrid(numRows, numColumns, diameter, centerDistance);
detector = FactoryFiducialCalibration.circleRegularGrid(config);
}
}
use of boofcv.abst.fiducial.calib.ConfigCircleHexagonalGrid 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());
}
use of boofcv.abst.fiducial.calib.ConfigCircleHexagonalGrid in project BoofCV by lessthanoptimal.
the class CreateCalibrationTargetGui method saveFile.
private void saveFile(boolean sendToPrinter) {
// grab the focus and force what the user is editing to be saved
File f;
// see where the document is to be sent
if (sendToPrinter) {
// dummy to make the code below happy and less complex
f = new File("");
} else {
f = FileSystemView.getFileSystemView().getHomeDirectory();
f = new File(f, "calibration_target.pdf");
f = BoofSwingUtil.fileChooser(this, false, f.getPath());
if (f == null) {
return;
}
if (f.isDirectory()) {
JOptionPane.showMessageDialog(this, "Can't save to a directory!");
return;
}
}
// Make sure the file has the correct extension
String outputFile = f.getAbsolutePath();
String ext = FilenameUtils.getExtension(outputFile);
if (ext.compareToIgnoreCase("pdf") != 0) {
outputFile = FilenameUtils.removeExtension(outputFile);
outputFile += "." + "pdf";
}
try {
switch(selectedType) {
case CHESSBOARD:
{
ConfigChessboard config = (ConfigChessboard) selectedCalib;
CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
generator.sendToPrinter = sendToPrinter;
generator.chessboard((float) config.squareWidth);
}
break;
case SQUARE_GRID:
{
ConfigSquareGrid config = (ConfigSquareGrid) selectedCalib;
CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
generator.sendToPrinter = sendToPrinter;
generator.squareGrid((float) config.squareWidth, (float) config.spaceWidth);
}
break;
case CIRCLE_GRID:
{
ConfigCircleRegularGrid config = (ConfigCircleRegularGrid) selectedCalib;
CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
generator.sendToPrinter = sendToPrinter;
generator.circleGrid((float) config.circleDiameter, (float) config.centerDistance);
}
break;
case CIRCLE_HEX:
{
ConfigCircleHexagonalGrid config = (ConfigCircleHexagonalGrid) selectedCalib;
CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
generator.sendToPrinter = sendToPrinter;
generator.circleHexagonal((float) config.circleDiameter, (float) config.centerDistance);
}
break;
default:
throw new RuntimeException("Unknown type " + selectedType);
}
} catch (IOException e) {
BoofSwingUtil.warningDialog(this, e);
}
}
Aggregations