Search in sources :

Example 21 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 22 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 23 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 24 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)

Example 25 with Point2Transform2_F64

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

the class VisualDepthOps method depthTo3D.

/**
 * Creates a point cloud from a depth image.
 * @param param Intrinsic camera parameters for depth image
 * @param depth depth image.  each value is in millimeters.
 * @param cloud Output point cloud
 */
public static void depthTo3D(CameraPinholeRadial param, GrayU16 depth, FastQueue<Point3D_F64> cloud) {
    cloud.reset();
    Point2Transform2_F64 p2n = LensDistortionOps.narrow(param).undistort_F64(true, false);
    Point2D_F64 n = new Point2D_F64();
    for (int y = 0; y < depth.height; y++) {
        int index = depth.startIndex + y * depth.stride;
        for (int x = 0; x < depth.width; x++) {
            int mm = depth.data[index++] & 0xFFFF;
            // skip pixels with no depth information
            if (mm == 0)
                continue;
            // this could all be precomputed to speed it up
            p2n.compute(x, y, n);
            Point3D_F64 p = cloud.grow();
            p.z = mm;
            p.x = n.x * p.z;
            p.y = n.y * p.z;
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64)

Aggregations

Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)28 Point2D_F64 (georegression.struct.point.Point2D_F64)15 Point3D_F64 (georegression.struct.point.Point3D_F64)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)6 SequencePoint2Transform2_F64 (boofcv.struct.distort.SequencePoint2Transform2_F64)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 PointTransformHomography_F64 (boofcv.alg.distort.PointTransformHomography_F64)4 AssociatedPair (boofcv.struct.geo.AssociatedPair)4 Se3_F64 (georegression.struct.se.Se3_F64)4 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 PointToPixelTransform_F64 (boofcv.alg.distort.PointToPixelTransform_F64)3 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)3 RectangleLength2D_F64 (georegression.struct.shapes.RectangleLength2D_F64)3 Point2D3D (boofcv.struct.geo.Point2D3D)2 GrayU8 (boofcv.struct.image.GrayU8)2 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)1 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)1 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)1 PinholePtoN_F64 (boofcv.alg.distort.pinhole.PinholePtoN_F64)1