Search in sources :

Example 1 with DetectorFiducialCalibration

use of boofcv.abst.geo.calibration.DetectorFiducialCalibration 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");
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) ConfigChessboard(boofcv.abst.fiducial.calib.ConfigChessboard)

Example 2 with DetectorFiducialCalibration

use of boofcv.abst.geo.calibration.DetectorFiducialCalibration 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");
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) ArrayList(java.util.ArrayList) ConfigChessboard(boofcv.abst.fiducial.calib.ConfigChessboard) File(java.io.File)

Example 3 with DetectorFiducialCalibration

use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.

the class GenericPlanarCalibrationDetectorChecks method dataNotRecycled.

/**
 * Make sure new instances of calibration points are returned each time
 */
@Test
public void dataNotRecycled() {
    for (Object layout : targetConfigs) {
        DetectorFiducialCalibration detector = createDetector(layout);
        GrayF32 original = renderEasy(layout, null);
        assertTrue(detector.process(original));
        CalibrationObservation found0 = detector.getDetectedPoints();
        assertTrue(detector.process(original));
        CalibrationObservation found1 = detector.getDetectedPoints();
        assertEquals(found0.size(), found1.size());
        assertTrue(found0 != found1);
        for (int i = 0; i < found0.size(); i++) {
            PointIndex2D_F64 p0 = found0.get(i);
            for (int j = 0; j < found1.size(); j++) {
                PointIndex2D_F64 p1 = found1.get(j);
                assertFalse(p0 == p1);
            }
        }
    }
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation) Test(org.junit.Test)

Example 4 with DetectorFiducialCalibration

use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.

the class GenericPlanarCalibrationDetectorChecks method pinhole_radial_fullview.

/**
 * Simulated scene using a pinhole camera model with radial distortion. Entire target is visible
 */
@Test
public void pinhole_radial_fullview() {
    CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("pinhole_radial.yaml"));
    SimulatePlanarWorld simulator = new SimulatePlanarWorld();
    simulator.setCamera(model);
    List<Point2D_F64> locations2D = new ArrayList<>();
    GrayF32 pattern = new GrayF32(1, 1);
    for (int i = 0; i < targetConfigs.size(); i++) {
        // System.out.println("*---------- Configuration "+i);
        failedToDetect = 0;
        DetectorFiducialCalibration detector = createDetector(targetConfigs.get(i));
        renderTarget(targetConfigs.get(i), simulatedTargetWidth, pattern, locations2D);
        simulator.resetScene();
        Se3_F64 markerToWorld = new Se3_F64();
        simulator.addTarget(markerToWorld, simulatedTargetWidth, pattern);
        // up close exploding - center
        markerToWorld.T.set(0, 0, 0.5);
        checkRenderedResults(detector, simulator, locations2D);
        // farther away centered
        markerToWorld.T.set(0, 0, 1);
        checkRenderedResults(detector, simulator, locations2D);
        markerToWorld.T.set(-0.33, 0, 1);
        checkRenderedResults(detector, simulator, locations2D);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0.8, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        markerToWorld.T.set(-0.33, 0.33, 1);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0.8, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        markerToWorld.T.set(0, -0.20, 1);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.8, -1, 0.8, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.8, -1, 1.8, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        markerToWorld.T.set(0, -0.15, 1);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.2, -1, 2.4, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
    }
    assertEquals(0, failedToDetect);
}
Also used : SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 5 with DetectorFiducialCalibration

use of boofcv.abst.geo.calibration.DetectorFiducialCalibration 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();
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) CameraUniversalOmni(boofcv.struct.calib.CameraUniversalOmni) ConfigChessboard(boofcv.abst.fiducial.calib.ConfigChessboard) CalibrateMonoPlanar(boofcv.abst.geo.calibration.CalibrateMonoPlanar) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Aggregations

DetectorFiducialCalibration (boofcv.abst.geo.calibration.DetectorFiducialCalibration)13 GrayF32 (boofcv.struct.image.GrayF32)10 Test (org.junit.Test)7 ConfigChessboard (boofcv.abst.fiducial.calib.ConfigChessboard)6 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 BufferedImage (java.awt.image.BufferedImage)4 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)3 ArrayList (java.util.ArrayList)3 CalibrateMonoPlanar (boofcv.abst.geo.calibration.CalibrateMonoPlanar)2 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2 CameraUniversalOmni (boofcv.struct.calib.CameraUniversalOmni)2 PointIndex2D_F64 (boofcv.struct.geo.PointIndex2D_F64)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Se3_F64 (georegression.struct.se.Se3_F64)2 File (java.io.File)1