Search in sources :

Example 31 with Point2Transform2_F64

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

the class ImplRectifyImageOps_F64 method allInsideLeft.

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

Example 32 with Point2Transform2_F64

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

the class ImplRectifyImageOps_F64 method transformRectToPixel.

public static Point2Transform2_F64 transformRectToPixel(CameraPinholeRadial param, DMatrixRMaj rectify) {
    Point2Transform2_F64 add_p_to_p = narrow(param).distort_F64(true, true);
    DMatrixRMaj rectifyInv = new DMatrixRMaj(3, 3);
    CommonOps_DDRM.invert(rectify, rectifyInv);
    PointTransformHomography_F64 removeRect = new PointTransformHomography_F64(rectifyInv);
    return new SequencePoint2Transform2_F64(removeRect, add_p_to_p);
}
Also used : PointTransformHomography_F64(boofcv.alg.distort.PointTransformHomography_F64) SequencePoint2Transform2_F64(boofcv.struct.distort.SequencePoint2Transform2_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) SequencePoint2Transform2_F64(boofcv.struct.distort.SequencePoint2Transform2_F64)

Example 33 with Point2Transform2_F64

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

the class TestRectifyImageOps method transform_PixelToRect_and_RectToPixel_F64.

@Test
public void transform_PixelToRect_and_RectToPixel_F64() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    DMatrixRMaj rect = new DMatrixRMaj(3, 3, true, 1.1, 0, 0, 0, 2, 0, 0.1, 0, 3);
    Point2Transform2_F64 forward = RectifyImageOps.transformPixelToRect(param, rect);
    Point2Transform2_F64 inverse = RectifyImageOps.transformRectToPixel(param, rect);
    double x = 20, y = 30;
    Point2D_F64 out = new Point2D_F64();
    forward.compute(x, y, out);
    // sanity check
    assertTrue(Math.abs(x - out.x) > 1e-8);
    assertTrue(Math.abs(y - out.y) > 1e-8);
    inverse.compute(out.x, out.y, out);
    assertEquals(x, out.x, 1e-5);
    assertEquals(y, out.y, 1e-5);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) Test(org.junit.Test)

Example 34 with Point2Transform2_F64

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

the class TestRectifyImageOps method transformPixelToRectNorm_F64.

/**
 * Test by using other tested functions, then manually applying the last step
 */
@Test
public void transformPixelToRectNorm_F64() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    DMatrixRMaj rect = new DMatrixRMaj(3, 3, true, 1.1, 0, 0, 0, 2, 0, 0.1, 0, 3);
    DMatrixRMaj rectK = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
    DMatrixRMaj rectK_inv = new DMatrixRMaj(3, 3);
    CommonOps_DDRM.invert(rectK, rectK_inv);
    Point2Transform2_F64 tranRect = RectifyImageOps.transformPixelToRect(param, rect);
    Point2Transform2_F64 alg = RectifyImageOps.transformPixelToRectNorm(param, rect, rectK);
    double x = 10, y = 20;
    // compute expected results
    Point2D_F64 rectified = new Point2D_F64();
    tranRect.compute(x, y, rectified);
    Point2D_F64 expected = new Point2D_F64();
    GeometryMath_F64.mult(rectK_inv, new Point2D_F64(rectified.x, rectified.y), expected);
    // compute the 'found' results
    Point2D_F64 found = new Point2D_F64();
    alg.compute(x, y, found);
    assertEquals(expected.x, found.x, 1e-4);
    assertEquals(expected.y, found.y, 1e-4);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) Test(org.junit.Test)

Example 35 with Point2Transform2_F64

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

Aggregations

Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)66 Point2D_F64 (georegression.struct.point.Point2D_F64)32 Test (org.junit.jupiter.api.Test)16 Point3D_F64 (georegression.struct.point.Point3D_F64)15 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)13 SequencePoint2Transform2_F64 (boofcv.struct.distort.SequencePoint2Transform2_F64)11 Se3_F64 (georegression.struct.se.Se3_F64)11 CameraPinhole (boofcv.struct.calib.CameraPinhole)9 LensDistortionBrown (boofcv.alg.distort.brown.LensDistortionBrown)8 PointToPixelTransform_F64 (boofcv.struct.distort.PointToPixelTransform_F64)8 ArrayList (java.util.ArrayList)8 PointTransformHomography_F64 (boofcv.alg.distort.PointTransformHomography_F64)7 AssociatedPair (boofcv.struct.geo.AssociatedPair)6 GrayF32 (boofcv.struct.image.GrayF32)6 LensDistortionPinhole (boofcv.alg.distort.pinhole.LensDistortionPinhole)5 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5 GrayU8 (boofcv.struct.image.GrayU8)5 RectangleLength2D_F64 (georegression.struct.shapes.RectangleLength2D_F64)5 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)3