use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.
the class ImplPerspectiveOps_F32 method calibrationMatrix.
public static FMatrixRMaj calibrationMatrix(CameraPinhole param, FMatrixRMaj K) {
if (K == null) {
K = new FMatrixRMaj(3, 3);
}
CommonOps_FDRM.fill(K, 0);
K.data[0] = (float) param.fx;
K.data[1] = (float) param.skew;
K.data[2] = (float) param.cx;
K.data[4] = (float) param.fy;
K.data[5] = (float) param.cy;
K.data[8] = 1;
return K;
}
use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.
the class ImplPerspectiveOps_F32 method renderPixel.
public static Point2D_F32 renderPixel(FMatrixRMaj worldToCamera, Point3D_F32 X) {
FMatrixRMaj P = worldToCamera;
float x = P.data[0] * X.x + P.data[1] * X.y + P.data[2] * X.z + P.data[3];
float y = P.data[4] * X.x + P.data[5] * X.y + P.data[6] * X.z + P.data[7];
float z = P.data[8] * X.x + P.data[9] * X.y + P.data[10] * X.z + P.data[11];
Point2D_F32 pixel = new Point2D_F32();
pixel.x = x / z;
pixel.y = y / z;
return pixel;
}
use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.
the class ImplPerspectiveOps_F32 method adjustIntrinsic.
public static <C extends CameraPinhole> C adjustIntrinsic(C parameters, FMatrixRMaj adjustMatrix, C adjustedParam) {
if (adjustedParam == null)
adjustedParam = parameters.createLike();
adjustedParam.set(parameters);
FMatrixRMaj K = ImplPerspectiveOps_F32.calibrationMatrix(parameters, null);
FMatrixRMaj K_adj = new FMatrixRMaj(3, 3);
CommonOps_FDRM.mult(adjustMatrix, K, K_adj);
ImplPerspectiveOps_F32.matrixToParam(K_adj, parameters.width, parameters.height, adjustedParam);
return adjustedParam;
}
use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestRectifyImageOps method fullViewLeft_uncalibrated.
@Test
public void fullViewLeft_uncalibrated() {
// do nothing rectification
FMatrixRMaj rect1 = CommonOps_FDRM.diag(2, 3, 1);
FMatrixRMaj rect2 = CommonOps_FDRM.diag(0.5f, 2, 1);
RectifyImageOps.fullViewLeft(300, 250, rect1, rect2);
// check left image
PointTransformHomography_F32 tran = new PointTransformHomography_F32(rect1);
checkInside(tran);
// the right view is not checked since it is not part of the contract
}
use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestRectifyImageOps method transform_PixelToRect_and_RectToPixel_F32.
/**
* Transforms and then performs the inverse transform to distorted rectified pixel
*/
@Test
public void transform_PixelToRect_and_RectToPixel_F32() {
CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
FMatrixRMaj rect = new FMatrixRMaj(3, 3, true, 1.1f, 0, 0, 0, 2, 0, 0.1f, 0, 3);
Point2Transform2_F32 forward = RectifyImageOps.transformPixelToRect(param, rect);
Point2Transform2_F32 inverse = RectifyImageOps.transformRectToPixel(param, rect);
float x = 20, y = 30;
Point2D_F32 out = new Point2D_F32();
forward.compute(x, y, out);
// sanity check
assertTrue(Math.abs(x - out.x) > 1e-4);
assertTrue(Math.abs(y - out.y) > 1e-4);
inverse.compute(out.x, out.y, out);
assertEquals(x, out.x, 1e-4);
assertEquals(y, out.y, 1e-4);
}
Aggregations