use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method scaleIntrinsic.
@Test
void scaleIntrinsic() {
Point3D_F64 X = new Point3D_F64(0.1, 0.3, 2);
CameraPinholeBrown param = new CameraPinholeBrown(200, 300, 2, 250, 260, 200, 300);
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(param, (DMatrixRMaj) null);
// find the pixel location in the unscaled image
Point2D_F64 a = PerspectiveOps.renderPixel(new Se3_F64(), K, X, null);
PerspectiveOps.scaleIntrinsic(param, 0.5);
K = PerspectiveOps.pinholeToMatrix(param, (DMatrixRMaj) null);
// find the pixel location in the scaled image
Point2D_F64 b = PerspectiveOps.renderPixel(new Se3_F64(), K, X, null);
assertEquals(a.x * 0.5, b.x, 1e-8);
assertEquals(a.y * 0.5, b.y, 1e-8);
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method guessIntrinsic_one.
@Test
void guessIntrinsic_one() {
double hfov = 30;
CameraPinholeBrown found = PerspectiveOps.createIntrinsic(640, 480, hfov, null);
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.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method convertPixelToNorm_intrinsic_F32.
@Test
void convertPixelToNorm_intrinsic_F32() {
CameraPinholeBrown intrinsic = new CameraPinholeBrown(100, 150, 0.1, 120, 209, 500, 600).fsetRadial(0.1, -0.05);
Point2Transform2_F32 p2n = LensDistortionFactory.narrow(intrinsic).undistort_F32(true, false);
Point2D_F32 pixel = new Point2D_F32(100, 120);
Point2D_F32 expected = new Point2D_F32();
p2n.compute(pixel.x, pixel.y, expected);
Point2D_F32 found = PerspectiveOps.convertPixelToNorm(intrinsic, pixel, null);
assertEquals(expected.x, found.x, UtilEjml.TEST_F32);
assertEquals(expected.y, found.y, UtilEjml.TEST_F32);
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestPinholeNtoP_F64 method basicTest.
@Test
void basicTest() {
CameraPinholeBrown p = new CameraPinholeBrown().fsetK(1, 2, 3, 4, 5, 200, 300);
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(p, (DMatrixRMaj) null);
Point2D_F64 pixel = new Point2D_F64(150, 200);
Point2D_F64 expected = new Point2D_F64();
Point2D_F64 found = new Point2D_F64();
GeometryMath_F64.mult(K, pixel, expected);
PinholeNtoP_F64 alg = new PinholeNtoP_F64();
alg.setK(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.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestLensDistortionOps method changeCameraModel.
/**
* This is a bit hard to test accurately. That would require computing distorted image and seeing everything lines
* up properly. For now we just check tos ee if things blow up.
*/
@Test
void changeCameraModel() {
CameraPinholeBrown original = new CameraPinholeBrown(200, 200, 0, 200, 200, 400, 400);
CameraPinhole desired = new CameraPinholeBrown(300, 300, 0, 200, 200, 400, 400);
CameraPinhole modified = new CameraPinhole();
BorderType[] borders = new BorderType[] { BorderType.EXTENDED, BorderType.SKIP, BorderType.ZERO, BorderType.REFLECT, BorderType.WRAP };
for (AdjustmentType adj : AdjustmentType.values()) {
for (BorderType border : borders) {
ImageDistort<GrayU8, GrayU8> alg = LensDistortionOps.changeCameraModel(adj, border, original, desired, modified, ImageType.single(GrayU8.class));
// do a few more tests to see of dubious value. if the underlying implementation changes
// this test will need to be updated
assertTrue(alg instanceof ImageDistortCache_SB);
ImageDistortCache_SB _alg = (ImageDistortCache_SB) alg;
assertTrue(_alg.interp instanceof ImplBilinearPixel_U8);
}
}
}
Aggregations