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