Search in sources :

Example 1 with CameraPinholeRadial

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

the class CalibrateStereoPlanar method process.

/**
 * Compute stereo calibration parameters
 *
 * @return Stereo calibration parameters
 */
public StereoParameters process() {
    // calibrate left and right cameras
    CameraPinholeRadial leftParam = calibrateMono(calibLeft, viewLeft);
    CameraPinholeRadial rightParam = calibrateMono(calibRight, viewRight);
    // fit motion from right to left
    Se3_F64 rightToLeft = computeRightToLeft();
    return new StereoParameters(leftParam, rightParam, rightToLeft);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64)

Example 2 with CameraPinholeRadial

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

the class CalibrateStereoPlanar method calibrateMono.

/**
 * Compute intrinsic calibration for one of the cameras
 */
private CameraPinholeRadial calibrateMono(CalibrateMonoPlanar calib, List<Se3_F64> location) {
    CameraPinholeRadial intrinsic = calib.process();
    Zhang99AllParam zhangParam = calib.getZhangParam();
    for (Zhang99AllParam.View v : zhangParam.views) {
        Se3_F64 pose = new Se3_F64();
        ConvertRotation3D_F64.rodriguesToMatrix(v.rotation, pose.getR());
        pose.getT().set(v.T);
        location.add(pose);
    }
    return intrinsic;
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Zhang99AllParam(boofcv.alg.geo.calibration.Zhang99AllParam) Se3_F64(georegression.struct.se.Se3_F64)

Example 3 with CameraPinholeRadial

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

the class TestLensDistortionOps method transformChangeModel_F32_EXPAND_modified.

/**
 * Sees if the adjusted intrinsic parameters is correct but computing normalized image coordinates first
 * with the original distorted image and then with the adjusted undistorted image.
 */
@Test
public void transformChangeModel_F32_EXPAND_modified() {
    // distorted pixel in original image
    float pixelX = 12.5f, pixelY = height - 3;
    CameraPinholeRadial orig = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
    CameraPinhole desired = new CameraPinhole(orig);
    Point2Transform2_F32 distToNorm = LensDistortionOps.narrow(orig).undistort_F32(true, false);
    Point2D_F32 norm = new Point2D_F32();
    distToNorm.compute(pixelX, pixelY, norm);
    CameraPinholeRadial adjusted = new CameraPinholeRadial();
    Point2Transform2_F32 distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.EXPAND, orig, desired, false, adjusted);
    Point2D_F32 adjPixel = new Point2D_F32();
    Point2D_F32 normFound = new Point2D_F32();
    distToAdj.compute(pixelX, pixelY, adjPixel);
    PerspectiveOps.convertPixelToNorm(adjusted, adjPixel, normFound);
    // see if the normalized image coordinates are the same
    assertEquals(norm.x, normFound.x, 1e-3);
    assertEquals(norm.y, normFound.y, 1e-3);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.Test)

Example 4 with CameraPinholeRadial

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

the class TestLensDistortionOps method transformChangeModel_F32_EXPAND.

/**
 * Checks the border of the returned transform.  Makes sure that no none-visible portion is visible.
 * Also makes sure that the requested inverse transform is actually the inverse.
 */
@Test
public void transformChangeModel_F32_EXPAND() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    CameraPinhole desired = new CameraPinhole(param);
    Point2Transform2_F32 adjToDist = LensDistortionOps.transformChangeModel_F32(AdjustmentType.EXPAND, param, desired, true, null);
    Point2Transform2_F32 distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.EXPAND, param, desired, false, null);
    checkInside(adjToDist, distToAdj);
    // distort it in the other direction
    param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(-0.1, -1e-4);
    adjToDist = LensDistortionOps.transformChangeModel_F32(AdjustmentType.EXPAND, param, desired, true, null);
    distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.EXPAND, param, desired, false, null);
    checkInside(adjToDist, distToAdj);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.Test)

Example 5 with CameraPinholeRadial

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

the class TestLensDistortionOps method transformChangeModel_F32_FULLVIEW.

/**
 * Checks the border of the returned transform.  Makes sure that the entire original image is visible.
 * Also makes sure that the requested inverse transform is actually the inverse.
 */
@Test
public void transformChangeModel_F32_FULLVIEW() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
    CameraPinhole desired = new CameraPinhole(param);
    Point2Transform2_F32 adjToDist = LensDistortionOps.transformChangeModel_F32(AdjustmentType.FULL_VIEW, param, desired, true, null);
    Point2Transform2_F32 distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.FULL_VIEW, param, desired, false, null);
    checkBorderOutside(adjToDist, distToAdj);
    param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(-0.1, -0.05);
    desired = new CameraPinhole(param);
    adjToDist = LensDistortionOps.transformChangeModel_F32(AdjustmentType.FULL_VIEW, param, desired, true, null);
    distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.FULL_VIEW, param, desired, false, null);
    checkBorderOutside(adjToDist, distToAdj);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.Test)

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