Search in sources :

Example 1 with ConfigChessboard

use of boofcv.abst.fiducial.calib.ConfigChessboard in project BoofCV by lessthanoptimal.

the class BaseCalibrationConfig method parseTarget.

protected void parseTarget(String where) throws FileNotFoundException {
    Reader input = media.openFile(where);
    SimpleStringNumberReader reader = new SimpleStringNumberReader('#');
    if (!reader.read(input))
        throw new RuntimeException("Parsing configuration failed");
    if (reader.remainingTokens() < 7)
        throw new RuntimeException("Not enough tokens in config file");
    String type = reader.nextString();
    numRadial = (int) reader.nextDouble();
    includeTangential = Boolean.parseBoolean(reader.nextString());
    assumeZeroSkew = Boolean.parseBoolean(reader.nextString());
    int numCols = (int) reader.nextDouble();
    int numRows = (int) reader.nextDouble();
    double width = reader.nextDouble();
    if (type.compareToIgnoreCase("square") == 0) {
        double space = reader.nextDouble();
        detector = FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(numRows, numCols, width, space));
    } else if (type.compareToIgnoreCase("chess") == 0) {
        detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(numRows, numCols, width));
    } else {
        throw new RuntimeException("Unknown type: " + type);
    }
    try {
        input.close();
    } catch (IOException e) {
    }
}
Also used : ConfigSquareGrid(boofcv.abst.fiducial.calib.ConfigSquareGrid) SimpleStringNumberReader(boofcv.io.SimpleStringNumberReader) Reader(java.io.Reader) ConfigChessboard(boofcv.abst.fiducial.calib.ConfigChessboard) SimpleStringNumberReader(boofcv.io.SimpleStringNumberReader) IOException(java.io.IOException)

Example 2 with ConfigChessboard

use of boofcv.abst.fiducial.calib.ConfigChessboard 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 3 with ConfigChessboard

use of boofcv.abst.fiducial.calib.ConfigChessboard 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 4 with ConfigChessboard

use of boofcv.abst.fiducial.calib.ConfigChessboard 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)

Example 5 with ConfigChessboard

use of boofcv.abst.fiducial.calib.ConfigChessboard 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)

Aggregations

ConfigChessboard (boofcv.abst.fiducial.calib.ConfigChessboard)14 DetectorFiducialCalibration (boofcv.abst.geo.calibration.DetectorFiducialCalibration)6 GrayF32 (boofcv.struct.image.GrayF32)5 ConfigSquareGrid (boofcv.abst.fiducial.calib.ConfigSquareGrid)4 ConfigCircleHexagonalGrid (boofcv.abst.fiducial.calib.ConfigCircleHexagonalGrid)3 ConfigCircleRegularGrid (boofcv.abst.fiducial.calib.ConfigCircleRegularGrid)3 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 BufferedImage (java.awt.image.BufferedImage)3 CalibrateMonoPlanar (boofcv.abst.geo.calibration.CalibrateMonoPlanar)2 RenderCalibrationTargetsGraphics2D (boofcv.gui.RenderCalibrationTargetsGraphics2D)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)1 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)1 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)1 MousePauseHelper (boofcv.gui.MousePauseHelper)1 PanelGridPanel (boofcv.gui.PanelGridPanel)1