use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method pinholeToMatrix_class_F.
@Test
void pinholeToMatrix_class_F() {
FMatrixRMaj K = PerspectiveOps.pinholeToMatrix(new CameraPinhole(1.0, 2, 3, 4, 5, 400, 500), (FMatrixRMaj) null);
assertEquals(1, K.get(0, 0), UtilEjml.TEST_F32);
assertEquals(2, K.get(1, 1), UtilEjml.TEST_F32);
assertEquals(3, K.get(0, 1), UtilEjml.TEST_F32);
assertEquals(4, K.get(0, 2), UtilEjml.TEST_F32);
assertEquals(5, K.get(1, 2), UtilEjml.TEST_F32);
assertEquals(1, K.get(2, 2), UtilEjml.TEST_F32);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method renderPixel_intrinsic.
@Test
void renderPixel_intrinsic() {
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
CameraPinhole intrinsic = new CameraPinhole(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, null);
assertEquals(expected.x, found.x, 1e-8);
assertEquals(expected.y, found.y, 1e-8);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method approximatePinhole.
@Test
void approximatePinhole() {
CameraPinhole original = PerspectiveOps.createIntrinsic(640, 480, 75, 70, null);
LensDistortionPinhole distortion = new LensDistortionPinhole(original);
CameraPinhole found = PerspectiveOps.approximatePinhole(distortion.undistort_F64(true, false), original.width, original.height);
assertEquals(original.width, found.width);
assertEquals(original.width, found.width);
assertEquals(original.skew, found.skew, UtilEjml.TEST_F64);
assertEquals(original.fx, found.fx, 1);
assertEquals(original.fy, found.fy, 1);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method renderPixel_SE3_homogenous.
@Test
void renderPixel_SE3_homogenous() {
var X3 = new Point3D_F64(0.1, -0.05, 3);
var X4 = new Point4D_F64(0.1, -0.05, 3, 1);
X4.scale(1.2);
Se3_F64 worldToCamera = SpecialEuclideanOps_F64.eulerXyz(0.2, 0.01, -0.03, 0.1, -0.05, 0.03, null);
CameraPinhole intrinsic = new CameraPinhole(100, 150, 0.1, 120, 209, 500, 600);
{
Point2D_F64 expected = PerspectiveOps.renderPixel(worldToCamera, intrinsic, X3, null);
Point2D_F64 found = PerspectiveOps.renderPixel(worldToCamera, intrinsic, X4, null);
assertEquals(expected.x, found.x, 1e-8);
assertEquals(expected.y, found.y, 1e-8);
}
// test to see if it can handle points at infinity. Translational component shouldn't matter
Se3_F64 noTranslate = worldToCamera.copy();
noTranslate.T.setTo(0, 0, 0);
{
X4.w = 0.0;
Point2D_F64 expected = PerspectiveOps.renderPixel(noTranslate, intrinsic, X3, null);
Point2D_F64 found = PerspectiveOps.renderPixel(worldToCamera, intrinsic, X4, null);
assertEquals(expected.x, found.x, 1e-8);
assertEquals(expected.y, found.y, 1e-8);
}
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestLensDistortionOps_F64 method transformChangeModel_EXPAND.
/**
* Checks the border of the returned transform. Makes sure that no none-visible portion is visible.
* Also makes sure that the requested inverse transform is actually the inverse.
*/
@Test
void transformChangeModel_EXPAND() {
CameraPinholeBrown param;
param = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
CameraPinhole desired = new CameraPinhole(param);
Point2Transform2_F64 adjToDist = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, param, desired, true, null);
Point2Transform2_F64 distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, param, desired, false, null);
checkInside(adjToDist, distToAdj);
// distort it in the other direction
param = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(-0.1, -1e-4);
adjToDist = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, param, desired, true, null);
distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, param, desired, false, null);
checkInside(adjToDist, distToAdj);
}
Aggregations