Search in sources :

Example 1 with Point2Transform2_F32

use of boofcv.struct.distort.Point2Transform2_F32 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 2 with Point2Transform2_F32

use of boofcv.struct.distort.Point2Transform2_F32 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 3 with Point2Transform2_F32

use of boofcv.struct.distort.Point2Transform2_F32 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)

Example 4 with Point2Transform2_F32

use of boofcv.struct.distort.Point2Transform2_F32 in project BoofCV by lessthanoptimal.

the class TestRectifyImageOps method fullViewLeft_calibrated.

/**
 * After the camera matrix has been adjusted and a forward rectification transform has been applied
 * the output image will be shrink and contained inside the output image.
 */
@Test
public void fullViewLeft_calibrated() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    // do nothing rectification
    FMatrixRMaj rect1 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rect2 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rectK = PerspectiveOps.calibrationMatrix(param, (FMatrixRMaj) null);
    RectifyImageOps.fullViewLeft(param, rect1, rect2, rectK);
    // check left image
    Point2Transform2_F32 tran = RectifyImageOps.transformPixelToRect(param, rect1);
    checkInside(tran);
// the right view is not checked since it is not part of the contract
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) Test(org.junit.Test)

Example 5 with Point2Transform2_F32

use of boofcv.struct.distort.Point2Transform2_F32 in project BoofCV by lessthanoptimal.

the class TestRectifyImageOps method allInsideLeft_calibrated.

@Test
public void allInsideLeft_calibrated() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    // do nothing rectification
    FMatrixRMaj rect1 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rect2 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rectK = PerspectiveOps.calibrationMatrix(param, (FMatrixRMaj) null);
    RectifyImageOps.allInsideLeft(param, rect1, rect2, rectK);
    // check left image
    Point2Transform2_F32 tran = RectifyImageOps.transformRectToPixel(param, rect1);
    checkInside(tran);
// the right view is not checked since it is not part of the contract
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) Test(org.junit.Test)

Aggregations

Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)36 Point2D_F32 (georegression.struct.point.Point2D_F32)16 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)10 SequencePoint2Transform2_F32 (boofcv.struct.distort.SequencePoint2Transform2_F32)9 CameraPinhole (boofcv.struct.calib.CameraPinhole)8 PointToPixelTransform_F32 (boofcv.struct.distort.PointToPixelTransform_F32)8 Test (org.junit.Test)8 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)5 FMatrixRMaj (org.ejml.data.FMatrixRMaj)5 PointTransformHomography_F32 (boofcv.alg.distort.PointTransformHomography_F32)4 RectangleLength2D_F32 (georegression.struct.shapes.RectangleLength2D_F32)4 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)2 InterpolatePixelS (boofcv.alg.interpolate.InterpolatePixelS)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Test (org.junit.jupiter.api.Test)2 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)1 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)1 ImagePanel (boofcv.gui.image.ImagePanel)1 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)1 PixelTransform2_F32 (boofcv.struct.distort.PixelTransform2_F32)1