Search in sources :

Example 6 with Point2Transform2_F64

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

the class ImplRectifyImageOps_F64 method transformPixelToRect.

public static Point2Transform2_F64 transformPixelToRect(CameraPinholeRadial param, DMatrixRMaj rectify) {
    Point2Transform2_F64 remove_p_to_p = narrow(param).undistort_F64(true, true);
    PointTransformHomography_F64 rectifyDistort = new PointTransformHomography_F64(rectify);
    return new SequencePoint2Transform2_F64(remove_p_to_p, rectifyDistort);
}
Also used : PointTransformHomography_F64(boofcv.alg.distort.PointTransformHomography_F64) SequencePoint2Transform2_F64(boofcv.struct.distort.SequencePoint2Transform2_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) SequencePoint2Transform2_F64(boofcv.struct.distort.SequencePoint2Transform2_F64)

Example 7 with Point2Transform2_F64

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

the class TestStereoProcessingBase method compute3D.

@Test
public void compute3D() {
    // point being viewed
    Point3D_F64 X = new Point3D_F64(-0.01, 0.1, 3);
    StereoParameters param = createStereoParam(width, height);
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param.left, (DMatrixRMaj) null);
    // compute the view in pixels of the point in the left and right cameras
    Point2D_F64 lensLeft = new Point2D_F64();
    Point2D_F64 lensRight = new Point2D_F64();
    SfmTestHelper.renderPointPixel(param, X, lensLeft, lensRight);
    StereoProcessingBase<GrayU8> alg = new StereoProcessingBase<>(GrayU8.class);
    alg.setCalibration(param);
    // Rectify the points
    Point2Transform2_F64 rectLeft = RectifyImageOps.transformPixelToRect(param.left, alg.getRect1());
    Point2Transform2_F64 rectRight = RectifyImageOps.transformPixelToRect(param.right, alg.getRect2());
    Point2D_F64 l = new Point2D_F64();
    Point2D_F64 r = new Point2D_F64();
    rectLeft.compute(lensLeft.x, lensLeft.y, l);
    rectRight.compute(lensRight.x, lensRight.y, r);
    // make sure I rectified it correctly
    assertEquals(l.y, r.y, 1);
    // find point in homogeneous coordinates
    Point3D_F64 found = new Point3D_F64();
    alg.computeHomo3D(l.x, l.y, found);
    // disparity between the two images
    double disparity = l.x - r.x;
    found.x /= disparity;
    found.y /= disparity;
    found.z /= disparity;
    assertTrue(found.isIdentical(X, 0.01));
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) GrayU8(boofcv.struct.image.GrayU8) StereoParameters(boofcv.struct.calib.StereoParameters) Test(org.junit.Test)

Example 8 with Point2Transform2_F64

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

the class TestStereoSparse3D method checkGeometry.

/**
 * Provide perfect image processing and validate the geometry
 */
@Test
public void checkGeometry() {
    Dummy disparity = new Dummy();
    StereoSparse3D alg = new StereoSparse3D(disparity, GrayF32.class);
    alg.setCalibration(param);
    Point3D_F64 X = new Point3D_F64(0.2, -0.34, 3);
    // original pixel coordinates
    Point2D_F64 x1 = PerspectiveOps.renderPixel(new Se3_F64(), K1, X);
    Point2D_F64 x2 = PerspectiveOps.renderPixel(param.rightToLeft.invert(null), K2, X);
    Point2Transform2_F64 pixelToRect1 = RectifyImageOps.transformPixelToRect(param.left, alg.rect1);
    Point2Transform2_F64 pixelToRect2 = RectifyImageOps.transformPixelToRect(param.right, alg.rect2);
    // rectified coordinates
    Point2D_F64 r1 = new Point2D_F64();
    Point2D_F64 r2 = new Point2D_F64();
    pixelToRect1.compute(x1.x, x1.y, r1);
    pixelToRect2.compute(x2.x, x2.y, r2);
    // compute the true disparity
    disparity.d = r1.x - r2.x;
    assertTrue(alg.process(x1.x, x1.y));
    double x = alg.getX() / alg.getW();
    double y = alg.getY() / alg.getW();
    double z = alg.getZ() / alg.getW();
    assertEquals(X.x, x, 1e-8);
    assertEquals(X.y, y, 1e-8);
    assertEquals(X.z, z, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 9 with Point2Transform2_F64

use of boofcv.struct.distort.Point2Transform2_F64 in project narchy by automenta.

the class ExampleStereoTwoViewsOneCamera method drawInliers.

/**
 * Draw inliers for debugging purposes.  Need to convert from normalized to pixel coordinates.
 */
public void drawInliers(CameraPinholeRadial intrinsic, List<AssociatedPair> normalized) {
    Point2Transform2_F64 n_to_p = LensDistortionOps.narrow(intrinsic).distort_F64(false, true);
    List<AssociatedPair> pixels = new ArrayList<>(normalized.size());
    for (AssociatedPair n : normalized) {
        AssociatedPair p = new AssociatedPair();
        n_to_p.compute(n.p1.x, n.p1.y, p.p1);
        n_to_p.compute(n.p2.x, n.p2.y, p.p2);
        pixels.add(p);
    }
    // display the results
    assocPanel.setAssociation(pixels);
    assocPanel.setImages(ConvertBufferedImage.extractBuffered(distortedPrev), ConvertBufferedImage.extractBuffered(distortedNext));
    assocPanel.repaint();
    assocPanel.setSize(500, 100);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) ArrayList(java.util.ArrayList)

Example 10 with Point2Transform2_F64

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

the class PinholeRadialToEquirectangular_F64 method setPinhole.

/**
 * Specifies the pinhole camera
 * @param pinhole intrinsic parameters of pinhole camera
 */
public void setPinhole(CameraPinholeRadial pinhole) {
    this.pinhole = pinhole;
    declareVectors(pinhole.width, pinhole.height);
    // computing the 3D ray through each pixel in the pinhole camera at it's canonical
    // location
    Point2Transform2_F64 pixelToNormalized = new LensDistortionRadialTangential(pinhole).undistort_F64(true, false);
    Point2D_F64 norm = new Point2D_F64();
    for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
        for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
            pixelToNormalized.compute(pixelX, pixelY, norm);
            Point3D_F64 v = vectors[pixelY * pinhole.width + pixelX];
            v.set(norm.x, norm.y, 1);
        }
    }
}
Also used : LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) 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