use of boofcv.abst.fiducial.calib.ConfigGridDimen in project BoofCV by lessthanoptimal.
the class ExampleCalibrateFisheye method main.
public static void main(String[] args) {
DetectSingleFiducialCalibration detector;
// Circle based calibration targets are not recommended because the sever lens distortion will change
// the apparent location of tangent points.
// Square Grid example
// detector = FactoryFiducialCalibration.squareGrid(null, new ConfigGridDimen(/*rows*/ 4, /*cols*/ 3, /*size*/ 30, /*space*/ 30));
// images = UtilIO.listAll(UtilIO.pathExample("calibration/fisheye/square_grid"));
// Chessboard Example
detector = FactoryFiducialCalibration.chessboardX(null, new ConfigGridDimen(/*rows*/
7, /*cols*/
5, /*size*/
30));
List<String> images = UtilIO.listAll(UtilIO.pathExample("calibration/fisheye/chessboard"));
// Declare and setup the calibration algorithm
var calibrationAlg = new CalibrateMonoPlanar(detector.getLayout());
// Specify the camera model to use. Here are a few examples.
//
calibrationAlg.configureUniversalOmni(/*zeroSkew*/
true, /*radial*/
2, /*tangential*/
false);
for (String n : images) {
BufferedImage input = UtilImageIO.loadImage(n);
if (input == null)
continue;
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
CameraModel intrinsic = calibrationAlg.process();
// save results to a file and print out
CalibrationIO.save(intrinsic, "fisheye.yaml");
calibrationAlg.printStatistics(System.out);
System.out.println();
System.out.println("--- Intrinsic Parameters ---");
System.out.println();
intrinsic.print();
}
use of boofcv.abst.fiducial.calib.ConfigGridDimen in project BoofCV by lessthanoptimal.
the class ExampleDetectCalibrationPoints method main.
public static void main(String[] args) {
// load the test image
// String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Square");
String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess");
BufferedImage orig = UtilImageIO.loadImageNotNull(directory + "/left01.jpg");
GrayF32 input = ConvertBufferedImage.convertFrom(orig, (GrayF32) null);
// To select different types of detectors add or remove comments below
DetectSingleFiducialCalibration detector;
// For chessboard targets, tune RADIUS parameter for your images
// detector = FactoryFiducialCalibration.squareGrid(null, new ConfigGridDimen(4, 3, 30, 30));
detector = FactoryFiducialCalibration.chessboardX(null, new ConfigGridDimen(/*rows*/
7, /*cols*/
5, /*shape size*/
30));
// process the image and check for failure condition
if (!detector.process(input))
throw new RuntimeException("Target detection failed!");
// Ordered observations of calibration points on the target
CalibrationObservation set = detector.getDetectedPoints();
// render and display the results
Graphics2D g2 = orig.createGraphics();
for (PointIndex2D_F64 p : set.points) VisualizeFeatures.drawPoint(g2, p.p.x, p.p.y, 3, Color.RED, true);
ShowImages.showWindow(orig, "Calibration Points", true);
}
use of boofcv.abst.fiducial.calib.ConfigGridDimen in project BoofCV by lessthanoptimal.
the class TestCreateCalibrationTarget method circle_regular.
@Test
void circle_regular() throws IOException {
createDocument("-r 8 -c 6 -o target -t CIRCLE_GRID -u cm -w 2 -d 3 -p LETTER");
BufferedImage image = loadPDF();
GrayF32 gray = new GrayF32(image.getWidth(), image.getHeight());
ConvertBufferedImage.convertFrom(image, gray);
DetectSingleFiducialCalibration detector = FactoryFiducialCalibration.circleRegularGrid(null, new ConfigGridDimen(8, 6, 2, 3));
assertTrue(detector.process(gray));
}
use of boofcv.abst.fiducial.calib.ConfigGridDimen in project BoofCV by lessthanoptimal.
the class TestCreateCalibrationTarget method square_grid.
@Test
void square_grid() throws IOException {
createDocument("-r 4 -c 3 -o target -t SQUARE_GRID -u cm -w 3 -s 3 -p LETTER\n");
BufferedImage image = loadPDF();
GrayF32 gray = new GrayF32(image.getWidth(), image.getHeight());
ConvertBufferedImage.convertFrom(image, gray);
CalibrationDetectorSquareGrid detector = FactoryFiducialCalibration.squareGrid(null, new ConfigGridDimen(4, 3, 3, 3));
assertTrue(detector.process(gray));
}
use of boofcv.abst.fiducial.calib.ConfigGridDimen in project BoofCV by lessthanoptimal.
the class TestCreateCalibrationTarget method chessboard.
@Test
void chessboard() throws IOException {
createDocument("-r 7 -c 5 -o target -t CHESSBOARD -u cm -w 3 -p LETTER");
BufferedImage image = loadPDF();
GrayF32 gray = new GrayF32(image.getWidth(), image.getHeight());
ConvertBufferedImage.convertFrom(image, gray);
CalibrationDetectorChessboardX detector = FactoryFiducialCalibration.chessboardX(null, new ConfigGridDimen(7, 5, 3));
assertTrue(detector.process(gray));
}
Aggregations