Search in sources :

Example 1 with CalibrateStereoPlanar

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

the class ExampleCalibrateStereo method process.

/**
 * Process calibration images, compute intrinsic parameters, save to a file
 */
public void process() {
    // Declare and setup the calibration algorithm
    CalibrateStereoPlanar calibratorAlg = new CalibrateStereoPlanar(detector.getLayout());
    calibratorAlg.configure(true, 2, false);
    // ensure the lists are in the same order
    Collections.sort(left);
    Collections.sort(right);
    for (int i = 0; i < left.size(); i++) {
        BufferedImage l = UtilImageIO.loadImage(left.get(i));
        BufferedImage r = UtilImageIO.loadImage(right.get(i));
        GrayF32 imageLeft = ConvertBufferedImage.convertFrom(l, (GrayF32) null);
        GrayF32 imageRight = ConvertBufferedImage.convertFrom(r, (GrayF32) null);
        CalibrationObservation calibLeft, calibRight;
        if (!detector.process(imageLeft)) {
            System.out.println("Failed to detect target in " + left.get(i));
            continue;
        }
        calibLeft = detector.getDetectedPoints();
        if (!detector.process(imageRight)) {
            System.out.println("Failed to detect target in " + right.get(i));
            continue;
        }
        calibRight = detector.getDetectedPoints();
        calibratorAlg.addPair(calibLeft, calibRight);
    }
    // Process and compute calibration parameters
    StereoParameters stereoCalib = calibratorAlg.process();
    // print out information on its accuracy and errors
    calibratorAlg.printStatistics();
    // save results to a file and print out
    CalibrationIO.save(stereoCalib, "stereo.yaml");
    stereoCalib.print();
// Note that the stereo baseline translation will be specified in the same units as the calibration grid.
// Which is in millimeters (mm) in this example.
}
Also used : CalibrateStereoPlanar(boofcv.abst.geo.calibration.CalibrateStereoPlanar) GrayF32(boofcv.struct.image.GrayF32) StereoParameters(boofcv.struct.calib.StereoParameters) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 2 with CalibrateStereoPlanar

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

the class CalibrateStereoPlanarGuiApp method configure.

/**
 * Configures the calibration tool. For the calibration images, the image index in both lists must
 * correspond to images taken at the same time.
 *
 * @param detector Calibration target detector.
 * @param assumeZeroSkew If true the skew parameter is assumed to be zero
 * @param leftImages Images taken by left camera.
 * @param rightImages Images taken by right camera.
 */
public void configure(DetectorFiducialCalibration detector, int numRadial, boolean includeTangential, boolean assumeZeroSkew, List<File> leftImages, List<File> rightImages) {
    if (leftImages.size() != rightImages.size())
        throw new IllegalArgumentException("Number of left and right images must be the same");
    this.detector = detector;
    calibrator = new CalibrateStereoPlanar(detector.getLayout());
    calibrator.configure(assumeZeroSkew, numRadial, includeTangential);
    this.leftImages = leftImages;
    this.rightImages = rightImages;
}
Also used : CalibrateStereoPlanar(boofcv.abst.geo.calibration.CalibrateStereoPlanar)

Aggregations

CalibrateStereoPlanar (boofcv.abst.geo.calibration.CalibrateStereoPlanar)2 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 StereoParameters (boofcv.struct.calib.StereoParameters)1 GrayF32 (boofcv.struct.image.GrayF32)1 BufferedImage (java.awt.image.BufferedImage)1