use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method convertPixelToNorm_intrinsic_F64.
@Test
public void convertPixelToNorm_intrinsic_F64() {
CameraPinholeRadial intrinsic = new CameraPinholeRadial(100, 150, 0.1, 120, 209, 500, 600);
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(intrinsic, (DMatrixRMaj) null);
DMatrixRMaj K_inv = new DMatrixRMaj(3, 3);
CommonOps_DDRM.invert(K, K_inv);
Point2D_F64 pixel = new Point2D_F64(100, 120);
Point2D_F64 expected = new Point2D_F64();
GeometryMath_F64.mult(K_inv, pixel, expected);
Point2D_F64 found = PerspectiveOps.convertPixelToNorm(intrinsic, pixel, null);
assertEquals(expected.x, found.x, 1e-8);
assertEquals(expected.y, found.y, 1e-8);
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method convertNormToPixel_intrinsic_F64.
@Test
public void convertNormToPixel_intrinsic_F64() {
CameraPinholeRadial intrinsic = new CameraPinholeRadial(100, 150, 0.1, 120, 209, 500, 600);
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(intrinsic, (DMatrixRMaj) null);
Point2D_F64 norm = new Point2D_F64(-0.1, 0.25);
Point2D_F64 expected = new Point2D_F64();
GeometryMath_F64.mult(K, norm, expected);
Point2D_F64 found = PerspectiveOps.convertNormToPixel(intrinsic, norm.x, norm.y, null);
assertEquals(expected.x, found.x, 1e-8);
assertEquals(expected.y, found.y, 1e-8);
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method adjustIntrinsic.
@Test
public void adjustIntrinsic() {
DMatrixRMaj B = new DMatrixRMaj(3, 3, true, 2, 0, 1, 0, 3, 2, 0, 0, 1);
CameraPinholeRadial param = new CameraPinholeRadial(200, 300, 2, 250, 260, 200, 300).fsetRadial(0.1, 0.3);
CameraPinholeRadial found = PerspectiveOps.adjustIntrinsic(param, B, null);
DMatrixRMaj A = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
DMatrixRMaj expected = new DMatrixRMaj(3, 3);
CommonOps_DDRM.mult(B, A, expected);
assertArrayEquals(param.radial, found.radial, 1e-8);
DMatrixRMaj foundM = PerspectiveOps.calibrationMatrix(found, (DMatrixRMaj) null);
assertTrue(MatrixFeatures_DDRM.isIdentical(expected, foundM, 1e-8));
}
use of boofcv.struct.calib.CameraPinholeRadial 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.calib.CameraPinholeRadial 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