Search in sources :

Example 26 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class VisualizeStereoVisualOdometryApp method refreshAll.

@Override
public void refreshAll(Object[] cookies) {
    numFaults = 0;
    if (cookies != null)
        whichAlg = (Integer) cookies[0];
    alg = createStereoDepth(whichAlg);
    alg.setCalibration(config);
    guiInfo.reset();
    handleRunningStatus(2);
    CameraPinholeRadial right = config.right;
    guiCam3D.init();
    guiCam3D.setFocalLength(300);
    guiCam3D.setStepSize(config.getBaseline());
    guiCam3D.setPreferredSize(new Dimension(right.width, right.height));
    guiCam3D.setMaximumSize(guiCam3D.getPreferredSize());
    startWorkerThread();
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial)

Example 27 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial 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 28 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class BenchmarkFiducialDetector method perform.

private static void perform(String directory, FiducialDetector detector) {
    CameraPinholeRadial intrinsic = CalibrationIO.load(new File(directory, "intrinsic.yaml"));
    // intrinsic.radial = null;
    // intrinsic.t1 = intrinsic.t2 = 0;
    BenchmarkFiducialDetector benchmark = new BenchmarkFiducialDetector(detector);
    benchmark.addImage(directory + "image0000.jpg");
    benchmark.addImage(directory + "image0001.jpg");
    benchmark.addImage(directory + "image0002.jpg");
    System.out.println("FPS = " + benchmark.benchmark(600));
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) File(java.io.File)

Example 29 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class ImplRectifyImageOps_F32 method allInsideLeft.

public static void allInsideLeft(CameraPinholeRadial paramLeft, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight, FMatrixRMaj rectifyK) {
    // need to take in account the order in which image distort will remove rectification later on
    paramLeft = new CameraPinholeRadial(paramLeft);
    Point2Transform2_F32 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
    RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(paramLeft.width, paramLeft.height, new PointToPixelTransform_F32(tranLeft));
    LensDistortionOps.roundInside(bound);
    float scaleX = paramLeft.width / (float) bound.width;
    float scaleY = paramLeft.height / (float) bound.height;
    float scale = (float) Math.max(scaleX, scaleY);
    adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32) SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 30 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class TestAssociateStereo2D method setup.

@Before
public void setup() {
    leftToRight = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.01, -0.001, 0.005, leftToRight.getR());
    leftToRight.getT().set(-0.1, 0, 0);
    param = new StereoParameters();
    param.rightToLeft = leftToRight.invert(null);
    param.left = new CameraPinholeRadial(400, 500, 0.1, 160, 120, 320, 240).fsetRadial(0, 0);
    param.right = new CameraPinholeRadial(380, 505, 0.05, 165, 115, 320, 240).fsetRadial(0, 0);
    descLeft = new FastQueue<TupleDesc_F64>(TupleDesc_F64.class, true) {

        @Override
        protected TupleDesc_F64 createInstance() {
            return new TupleDesc_F64(10);
        }
    };
    descRight = new FastQueue<TupleDesc_F64>(TupleDesc_F64.class, true) {

        @Override
        protected TupleDesc_F64 createInstance() {
            return new TupleDesc_F64(10);
        }
    };
    pointsLeft.reset();
    pointsRight.reset();
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64) Before(org.junit.Before)

Aggregations

CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)81 Test (org.junit.Test)37 Se3_F64 (georegression.struct.se.Se3_F64)26 GrayF32 (boofcv.struct.image.GrayF32)19 Point2D_F64 (georegression.struct.point.Point2D_F64)16 File (java.io.File)15 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)12 BufferedImage (java.awt.image.BufferedImage)12 DMatrixRMaj (org.ejml.data.DMatrixRMaj)12 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)10 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)9 CameraPinhole (boofcv.struct.calib.CameraPinhole)9 Point3D_F64 (georegression.struct.point.Point3D_F64)8 ArrayList (java.util.ArrayList)7 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)6 StereoParameters (boofcv.struct.calib.StereoParameters)6 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)6 Point2D_F32 (georegression.struct.point.Point2D_F32)5 FMatrixRMaj (org.ejml.data.FMatrixRMaj)5 GrayU8 (boofcv.struct.image.GrayU8)4