use of boofcv.struct.calib.CameraPinholeRadial 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 boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method renderPixel_intrinsic.
@Test
public void renderPixel_intrinsic() {
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
CameraPinholeRadial intrinsic = new CameraPinholeRadial(100, 150, 0.1, 120, 209, 500, 600);
double normX = X.x / X.z;
double normY = X.y / X.z;
Point2D_F64 expected = new Point2D_F64();
PerspectiveOps.convertNormToPixel(intrinsic, normX, normY, expected);
Point2D_F64 found = PerspectiveOps.renderPixel(intrinsic, X);
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 guessIntrinsic_one.
@Test
public void guessIntrinsic_one() {
double hfov = 30;
CameraPinholeRadial found = PerspectiveOps.createIntrinsic(640, 480, hfov);
assertEquals(UtilAngle.degreeToRadian(hfov), 2.0 * Math.atan(found.cx / found.fx), 1e-6);
assertEquals(found.fx, found.fy, 1e-6);
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method scaleIntrinsic.
@Test
public void scaleIntrinsic() {
Point3D_F64 X = new Point3D_F64(0.1, 0.3, 2);
CameraPinholeRadial param = new CameraPinholeRadial(200, 300, 2, 250, 260, 200, 300);
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
// find the pixel location in the unscaled image
Point2D_F64 a = PerspectiveOps.renderPixel(new Se3_F64(), K, X);
PerspectiveOps.scaleIntrinsic(param, 0.5);
K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
// find the pixel location in the scaled image
Point2D_F64 b = PerspectiveOps.renderPixel(new Se3_F64(), K, X);
assertEquals(a.x * 0.5, b.x, 1e-8);
assertEquals(a.y * 0.5, b.y, 1e-8);
}
use of boofcv.struct.calib.CameraPinholeRadial 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
}
Aggregations