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