Search in sources :

Example 26 with FMatrixRMaj

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;
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj)

Example 27 with FMatrixRMaj

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;
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 28 with FMatrixRMaj

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;
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj)

Example 29 with FMatrixRMaj

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
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) PointTransformHomography_F32(boofcv.alg.distort.PointTransformHomography_F32) Test(org.junit.Test)

Example 30 with FMatrixRMaj

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);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) Test(org.junit.Test)

Aggregations

FMatrixRMaj (org.ejml.data.FMatrixRMaj)36 DMatrixRMaj (org.ejml.data.DMatrixRMaj)10 Test (org.junit.Test)8 Point2D_F32 (georegression.struct.point.Point2D_F32)7 Se3_F64 (georegression.struct.se.Se3_F64)7 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)6 PointTransformHomography_F32 (boofcv.alg.distort.PointTransformHomography_F32)5 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)5 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)4 BufferedImage (java.awt.image.BufferedImage)4 RectifiedPairPanel (boofcv.gui.stereo.RectifiedPairPanel)3 GrayF32 (boofcv.struct.image.GrayF32)3 GrayU8 (boofcv.struct.image.GrayU8)3 Planar (boofcv.struct.image.Planar)3 ArrayList (java.util.ArrayList)3 Test (org.junit.jupiter.api.Test)3 Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)2 CameraPinhole (boofcv.struct.calib.CameraPinhole)2 PointToPixelTransform_F32 (boofcv.struct.distort.PointToPixelTransform_F32)2