Search in sources :

Example 6 with ConfigGridDimen

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();
}
Also used : ConfigGridDimen(boofcv.abst.fiducial.calib.ConfigGridDimen) DetectSingleFiducialCalibration(boofcv.abst.geo.calibration.DetectSingleFiducialCalibration) CameraModel(boofcv.struct.calib.CameraModel) GrayF32(boofcv.struct.image.GrayF32) CalibrateMonoPlanar(boofcv.abst.geo.calibration.CalibrateMonoPlanar) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 7 with ConfigGridDimen

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);
}
Also used : ConfigGridDimen(boofcv.abst.fiducial.calib.ConfigGridDimen) DetectSingleFiducialCalibration(boofcv.abst.geo.calibration.DetectSingleFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 8 with ConfigGridDimen

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));
}
Also used : ConfigGridDimen(boofcv.abst.fiducial.calib.ConfigGridDimen) DetectSingleFiducialCalibration(boofcv.abst.geo.calibration.DetectSingleFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) Test(org.junit.jupiter.api.Test)

Example 9 with ConfigGridDimen

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));
}
Also used : ConfigGridDimen(boofcv.abst.fiducial.calib.ConfigGridDimen) GrayF32(boofcv.struct.image.GrayF32) CalibrationDetectorSquareGrid(boofcv.abst.fiducial.calib.CalibrationDetectorSquareGrid) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) Test(org.junit.jupiter.api.Test)

Example 10 with ConfigGridDimen

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));
}
Also used : ConfigGridDimen(boofcv.abst.fiducial.calib.ConfigGridDimen) CalibrationDetectorChessboardX(boofcv.abst.fiducial.calib.CalibrationDetectorChessboardX) GrayF32(boofcv.struct.image.GrayF32) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigGridDimen (boofcv.abst.fiducial.calib.ConfigGridDimen)12 GrayF32 (boofcv.struct.image.GrayF32)8 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)7 BufferedImage (java.awt.image.BufferedImage)7 DetectSingleFiducialCalibration (boofcv.abst.geo.calibration.DetectSingleFiducialCalibration)4 Test (org.junit.jupiter.api.Test)4 CalibrateMonoPlanar (boofcv.abst.geo.calibration.CalibrateMonoPlanar)2 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)2 GrayU8 (boofcv.struct.image.GrayU8)2 CalibrationDetectorChessboardX (boofcv.abst.fiducial.calib.CalibrationDetectorChessboardX)1 CalibrationDetectorCircleHexagonalGrid (boofcv.abst.fiducial.calib.CalibrationDetectorCircleHexagonalGrid)1 CalibrationDetectorSquareGrid (boofcv.abst.fiducial.calib.CalibrationDetectorSquareGrid)1 ConfigECoCheckMarkers (boofcv.abst.fiducial.calib.ConfigECoCheckMarkers)1 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)1 LensDistortionBrown (boofcv.alg.distort.brown.LensDistortionBrown)1 ECoCheckGenerator (boofcv.alg.fiducial.calib.ecocheck.ECoCheckGenerator)1 ECoCheckUtils (boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils)1 HammingChessboardGenerator (boofcv.alg.fiducial.calib.hammingchess.HammingChessboardGenerator)1 HammingGridGenerator (boofcv.alg.fiducial.calib.hamminggrids.HammingGridGenerator)1 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)1