Search in sources :

Example 1 with FMatrixRMaj

use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestNarrowToWidePtoP_F32 method rotateCamera.

/**
 * Rotate the camera and see if the point moves in the expected way
 */
@Test
public void rotateCamera() {
    NarrowToWidePtoP_F32 alg = createAlg();
    Point2D_F32 found = new Point2D_F32();
    FMatrixRMaj R = ConvertRotation3D_F32.eulerToMatrix(EulerType.YXZ, 0.1f, 0, 0, null);
    alg.setRotationWideToNarrow(R);
    alg.compute(250, 250, found);
    assertTrue(480 < found.x - 5);
    R = ConvertRotation3D_F32.eulerToMatrix(EulerType.YXZ, -0.1f, 0, 0, null);
    alg.setRotationWideToNarrow(R);
    alg.compute(250, 250, found);
    assertTrue(480 > found.x + 5);
    R = ConvertRotation3D_F32.eulerToMatrix(EulerType.YXZ, 0, -0.1f, 0, null);
    alg.setRotationWideToNarrow(R);
    alg.compute(250, 250, found);
    assertTrue(480 < found.y - 5);
    R = ConvertRotation3D_F32.eulerToMatrix(EulerType.YXZ, 0, 0.1f, 0, null);
    alg.setRotationWideToNarrow(R);
    alg.compute(250, 250, found);
    assertTrue(480 > found.y + 5);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 2 with FMatrixRMaj

use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestPinholeNtoP_F32 method basicTest.

@Test
public void basicTest() {
    CameraPinholeRadial p = new CameraPinholeRadial().fsetK(1, 2, 3, 4, 5, 200, 300);
    FMatrixRMaj K = PerspectiveOps.calibrationMatrix(p, (FMatrixRMaj) null);
    Point2D_F32 pixel = new Point2D_F32(150, 200);
    Point2D_F32 expected = new Point2D_F32();
    Point2D_F32 found = new Point2D_F32();
    GeometryMath_F32.mult(K, pixel, expected);
    PinholeNtoP_F32 alg = new PinholeNtoP_F32();
    alg.set(p.fx, p.fy, p.skew, p.cx, p.cy);
    alg.compute(pixel.x, pixel.y, found);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 3 with FMatrixRMaj

use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestRectifyImageOps method fullViewLeft_calibrated.

/**
 * After the camera matrix has been adjusted and a forward rectification transform has been applied
 * the output image will be shrink and contained inside the output image.
 */
@Test
public void fullViewLeft_calibrated() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    // do nothing rectification
    FMatrixRMaj rect1 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rect2 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rectK = PerspectiveOps.calibrationMatrix(param, (FMatrixRMaj) null);
    RectifyImageOps.fullViewLeft(param, rect1, rect2, rectK);
    // check left image
    Point2Transform2_F32 tran = RectifyImageOps.transformPixelToRect(param, rect1);
    checkInside(tran);
// the right view is not checked since it is not part of the contract
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) Test(org.junit.Test)

Example 4 with FMatrixRMaj

use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestRectifyImageOps method allInsideLeft_calibrated.

@Test
public void allInsideLeft_calibrated() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    // do nothing rectification
    FMatrixRMaj rect1 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rect2 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rectK = PerspectiveOps.calibrationMatrix(param, (FMatrixRMaj) null);
    RectifyImageOps.allInsideLeft(param, rect1, rect2, rectK);
    // check left image
    Point2Transform2_F32 tran = RectifyImageOps.transformRectToPixel(param, rect1);
    checkInside(tran);
// the right view is not checked since it is not part of the contract
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) Test(org.junit.Test)

Example 5 with FMatrixRMaj

use of org.ejml.data.FMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestPinholePtoN_F32 method basic.

/**
 * Do the same calculation but using a different but equivalent equation
 */
@Test
public void basic() {
    PinholePtoN_F32 alg = new PinholePtoN_F32();
    alg.set(fx, fy, skew, x_c, y_c);
    Point2D_F32 in = new Point2D_F32(100, 120);
    Point2D_F32 out = new Point2D_F32();
    alg.compute(in.x, in.y, out);
    Point2D_F32 expected = new Point2D_F32();
    FMatrixRMaj K_inv = new FMatrixRMaj(3, 3, true, fx, skew, x_c, 0, fy, y_c, 0, 0, 1);
    CommonOps_FDRM.invert(K_inv);
    GeometryMath_F32.mult(K_inv, in, expected);
    assertEquals(expected.x, out.x, 1e-5);
    assertEquals(expected.y, out.y, 1e-5);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) Point2D_F32(georegression.struct.point.Point2D_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