Search in sources :

Example 6 with DetectorFiducialCalibration

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

Example 7 with DetectorFiducialCalibration

use of boofcv.abst.geo.calibration.DetectorFiducialCalibration 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.loadImage(directory + "/left01.jpg");
    GrayF32 input = ConvertBufferedImage.convertFrom(orig, (GrayF32) null);
    // To select different types of detectors add or remove comments below
    DetectorFiducialCalibration detector;
    // For chessboard targets, tune RADIUS parameter for your images
    // detector = FactoryCalibrationTarget.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
    detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 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.x, p.y, 3, Color.RED, true);
    ShowImages.showWindow(orig, "Calibration Points", true);
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) ConfigChessboard(boofcv.abst.fiducial.calib.ConfigChessboard) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 8 with DetectorFiducialCalibration

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

the class GenericPlanarCalibrationDetectorChecks method checkDetectionsResetOnFailure.

/**
 * First call something was detected, second call nothing was detected.  it should return an empty list
 */
@Test
public void checkDetectionsResetOnFailure() {
    DetectorFiducialCalibration detector = createDetector(targetConfigs.get(0));
    GrayF32 original = renderEasy(targetConfigs.get(0), null);
    detector.process(original);
    assertTrue(detector.getDetectedPoints().size() > 0);
    detector.process(new GrayF32(300, 400));
    assertTrue(detector.getDetectedPoints() != null);
    assertTrue(detector.getDetectedPoints().size() == 0);
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Example 9 with DetectorFiducialCalibration

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

the class GenericPlanarCalibrationDetectorChecks method fisheye_fullview.

/**
 * See if it can detect targets distorted by fisheye lens. Entire target is always seen
 */
@Test
public void fisheye_fullview() {
    CameraUniversalOmni model = CalibrationIO.load(getClass().getResource("fisheye.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++) {
        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);
        failedToDetect = 0;
        for (int j = 0; j < fisheye_poses.size(); j++) {
            // System.out.println("fisheye pose = "+j);
            markerToWorld.set(fisheye_poses.get(j));
            checkRenderedResults(detector, simulator, locations2D);
        }
    }
    assertTrue(failedToDetect <= fisheyeAllowedFails);
}
Also used : SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) CameraUniversalOmni(boofcv.struct.calib.CameraUniversalOmni) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 10 with DetectorFiducialCalibration

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

the class GenericPlanarCalibrationDetectorChecks method checkDetectionsNonnull.

/**
 * Nothing was detected.  make sure it doesn't return null.
 */
@Test
public void checkDetectionsNonnull() {
    for (Object layout : targetConfigs) {
        DetectorFiducialCalibration detector = createDetector(layout);
        detector.process(new GrayF32(300, 400));
        assertTrue(detector.getDetectedPoints() != null);
        assertTrue(detector.getDetectedPoints().size() == 0);
    }
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

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