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);
}
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);
}
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);
}
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);
}
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;
}
}
}
Aggregations