use of boofcv.abst.fiducial.calib.ConfigChessboard 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.ConfigChessboard in project BoofCV by lessthanoptimal.
the class CalibratePinholePlanarGuiApp method main.
public static void main(String[] args) {
DetectorFiducialCalibration detector = // FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(4,3,30,30));
FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
// FactoryFiducialCalibration.circleHexagonalGrid(new ConfigCircleHexagonalGrid(5, 8, 1, 6));
List<String> images;
// images = UtilIO.directoryList(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_Square"),"frame");
images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_Chess"), "frame");
// images = UtilIO.directoryList(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_CircleHexagonal"),"image");
// images = UtilIO.directoryList(UtilIO.pathExample("calibration/mono/PULNiX_CCD_6mm_Zhang"),"CalibIm");
// images = UtilIO.directoryList(UtilIO.pathExample("calibration//stereo/Bumblebee2_Square"),"left");
CalibratePinholePlanarGuiApp app = new CalibratePinholePlanarGuiApp();
app.configure(detector, images, 2, false);
JFrame frame = new JFrame("Pinhole Calribation with Planar Targets");
frame.add(app, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
app.process("intrinsic.yaml");
}
use of boofcv.abst.fiducial.calib.ConfigChessboard in project BoofCV by lessthanoptimal.
the class CalibrateStereoPlanarGuiApp method main.
public static void main(String[] args) {
DetectorFiducialCalibration detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
// FactoryCalibrationTarget.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess");
// String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Square");
List<String> leftImages = UtilIO.listByPrefix(directory, "left");
List<String> rightImages = UtilIO.listByPrefix(directory, "right");
Collections.sort(leftImages);
Collections.sort(rightImages);
List<File> leftFiles = new ArrayList<>();
List<File> rightFiles = new ArrayList<>();
for (String s : leftImages) {
leftFiles.add(new File(s));
}
for (String s : rightImages) {
rightFiles.add(new File(s));
}
CalibrateStereoPlanarGuiApp app = new CalibrateStereoPlanarGuiApp();
app.configure(detector, 2, false, true, leftFiles, rightFiles);
ShowImages.showWindow(app, "Planar Stereo Calibration", true);
app.process("stereo.yaml");
}
use of boofcv.abst.fiducial.calib.ConfigChessboard in project BoofCV by lessthanoptimal.
the class ExampleCalibrateFisheye method main.
public static void main(String[] args) {
DetectorFiducialCalibration detector;
List<String> images;
// Circle based calibration targets not not recommended because the sever lens distortion will change
// the apparent location of tangent points.
// Square Grid example
// detector = FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
// images = UtilIO.listAll(UtilIO.pathExample("calibration/fisheye/square_grid"));
// Chessboard Example
detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
images = UtilIO.listAll(UtilIO.pathExample("calibration/fisheye/chessboard"));
// Declare and setup the calibration algorithm
CalibrateMonoPlanar calibrationAlg = new CalibrateMonoPlanar(detector.getLayout());
// tell it type type of target and which parameters to estimate
calibrationAlg.configureUniversalOmni(true, 2, false);
for (String n : images) {
BufferedImage input = UtilImageIO.loadImage(n);
if (input != null) {
GrayF32 image = ConvertBufferedImage.convertFrom(input, (GrayF32) null);
if (detector.process(image)) {
calibrationAlg.addImage(detector.getDetectedPoints().copy());
} else {
System.err.println("Failed to detect target in " + n);
}
}
}
// process and compute intrinsic parameters
CameraUniversalOmni intrinsic = calibrationAlg.process();
// save results to a file and print out
CalibrationIO.save(intrinsic, "fisheye.yaml");
calibrationAlg.printStatistics();
System.out.println();
System.out.println("--- Intrinsic Parameters ---");
System.out.println();
intrinsic.print();
}
use of boofcv.abst.fiducial.calib.ConfigChessboard in project BoofCV by lessthanoptimal.
the class ExampleCalibrateMonocular method main.
public static void main(String[] args) {
DetectorFiducialCalibration detector;
List<String> images;
// Regular Circle Example
// detector = FactoryFiducialCalibration.circleRegularGrid(new ConfigCircleRegularGrid(8, 10, 1.5, 2.5));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_CircleRegular"),"image");
// Hexagonal Circle Example
// detector = FactoryFiducialCalibration.circleHexagonalGrid(new ConfigCircleHexagonalGrid(24, 28, 1, 1.2));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_CircleHexagonal"),"image");
// Square Grid example
// detector = FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/stereo/Bumblebee2_Square"),"left");
// Chessboard Example
detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess"), "left");
// Declare and setup the calibration algorithm
CalibrateMonoPlanar calibrationAlg = new CalibrateMonoPlanar(detector.getLayout());
// tell it type type of target and which parameters to estimate
calibrationAlg.configurePinhole(true, 2, false);
for (String n : images) {
BufferedImage input = UtilImageIO.loadImage(n);
if (input != null) {
GrayF32 image = ConvertBufferedImage.convertFrom(input, (GrayF32) null);
if (detector.process(image)) {
calibrationAlg.addImage(detector.getDetectedPoints().copy());
} else {
System.err.println("Failed to detect target in " + n);
}
}
}
// process and compute intrinsic parameters
CameraPinholeRadial intrinsic = calibrationAlg.process();
// save results to a file and print out
CalibrationIO.save(intrinsic, "intrinsic.yaml");
calibrationAlg.printStatistics();
System.out.println();
System.out.println("--- Intrinsic Parameters ---");
System.out.println();
intrinsic.print();
}
Aggregations