Search in sources :

Example 76 with CameraPinholeRadial

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

the class TestLensDistortionOps method transformChangeModel_F32_FULLVIEW_modified.

/**
 * Checks to see if the returned modified model is correct
 */
@Test
public void transformChangeModel_F32_FULLVIEW_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.FULL_VIEW, 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 77 with CameraPinholeRadial

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

the class TestLensDistortionOps method transformChangeModel_F32_NONE_modified.

@Test
public void transformChangeModel_F32_NONE_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);
    CameraPinhole adjusted = new CameraPinhole();
    Point2Transform2_F32 distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.NONE, 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 78 with CameraPinholeRadial

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

the class WrapVisOdomPixelDepthPnP method setCalibration.

@Override
public void setCalibration(StereoParameters parameters) {
    stereo.setCalibration(parameters);
    CameraPinholeRadial l = parameters.left;
    Point2Transform2_F64 leftPixelToNorm = narrow(l).undistort_F64(true, false);
    Point2Transform2_F64 leftNormToPixel = narrow(l).distort_F64(false, true);
    alg.setPixelToNorm(leftPixelToNorm);
    alg.setNormToPixel(leftNormToPixel);
    distance.setIntrinsic(l.fx, l.fy, l.skew);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64)

Example 79 with CameraPinholeRadial

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

the class StereoConsistencyCheck method setCalibration.

public void setCalibration(StereoParameters param) {
    CameraPinholeRadial left = param.getLeft();
    CameraPinholeRadial right = param.getRight();
    // compute rectification
    RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated();
    Se3_F64 leftToRight = param.getRightToLeft().invert(null);
    // original camera calibration matrices
    DMatrixRMaj K1 = PerspectiveOps.calibrationMatrix(left, (DMatrixRMaj) null);
    DMatrixRMaj K2 = PerspectiveOps.calibrationMatrix(right, (DMatrixRMaj) null);
    rectifyAlg.process(K1, new Se3_F64(), K2, leftToRight);
    // rectification matrix for each image
    DMatrixRMaj rect1 = rectifyAlg.getRect1();
    DMatrixRMaj rect2 = rectifyAlg.getRect2();
    leftImageToRect = RectifyImageOps.transformPixelToRect(param.left, rect1);
    rightImageToRect = RectifyImageOps.transformPixelToRect(param.right, rect2);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) RectifyCalibrated(boofcv.alg.geo.rectify.RectifyCalibrated) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64)

Example 80 with CameraPinholeRadial

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

the class TestMonocularPlaneVisualOdometryScaleInput method process.

@Test
public void process() {
    image = null;
    CameraPinholeRadial intrinsic = createIntrinsic();
    Dummy dummy = new Dummy();
    MonocularPlaneVisualOdometry<GrayF32> alg = new MonocularPlaneVisualOdometryScaleInput<>(dummy, 0.5);
    alg.setCalibration(new MonoPlaneParameters(intrinsic, new Se3_F64()));
    GrayF32 inputImage = new GrayF32(width, height);
    alg.process(inputImage);
    assertTrue(inputImage != image);
    assertEquals(320, image.width);
    assertEquals(160, image.height);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) MonoPlaneParameters(boofcv.struct.calib.MonoPlaneParameters) Se3_F64(georegression.struct.se.Se3_F64) 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