use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestPRnPDirectLinearTransform method many_perfect.
/**
* No noise. Redundant data
*/
@Test
void many_perfect() {
Se3_F64 m = SpecialEuclideanOps_F64.eulerXyz(0.01, 0.1, 1, 0.01, -0.02, 0.015, null);
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(new CameraPinhole(500, 500, 0, 250, 250, 1000, 1000), (DMatrixRMaj) null);
PRnPDirectLinearTransform alg = new PRnPDirectLinearTransform();
DMatrixRMaj P = PerspectiveOps.createCameraMatrix(m.R, m.T, K, null);
for (int trial = 0; trial < 5; trial++) {
generateScene(40 - trial, P, false);
DMatrixRMaj found = new DMatrixRMaj(3, 4);
assertTrue(alg.process(worldPts, pixelsView2, found));
CommonOps_DDRM.divide(P, NormOps_DDRM.normF(P));
CommonOps_DDRM.divide(found, NormOps_DDRM.normF(found));
if (Math.signum(P.get(0, 0)) != Math.signum(found.get(0, 0))) {
CommonOps_DDRM.scale(-1, found);
}
assertTrue(MatrixFeatures_DDRM.isIdentical(P, found, UtilEjml.TEST_F64));
}
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class CommonAutoCalibrationChecks method renderTranslationOnly.
public void renderTranslationOnly(CameraPinhole camera) {
List<CameraPinhole> cameras = new ArrayList<>();
for (int i = 0; i < 11; i++) {
Se3_F64 R = new Se3_F64();
Se3_F64 axis = new Se3_F64();
axis.T.z = -2 + rand.nextGaussian() * 0.01;
axis.T.x = rand.nextGaussian() * 0.4;
axis.T.y = rand.nextGaussian() * 0.4;
Se3_F64 cameraToWorld = new Se3_F64();
R.concat(axis, cameraToWorld);
listCameraToWorld.add(cameraToWorld);
cameras.add(camera);
}
render(cameras);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class CommonThreeViewSelfCalibration method standardScene.
protected void standardScene() {
cameraA = new CameraPinhole(600, 600, 0.1, 400, 410, 800, 600);
cameraB = cameraC = cameraA;
list_world_to_cameras = new ArrayList<>();
list_world_to_cameras.add(eulerXyz(0, 0, -2, 0, 0, 0.0, null).invert(null));
list_world_to_cameras.add(eulerXyz(1, 0.1, -2.1, -0.1, 0, 0.05, null).invert(null));
list_world_to_cameras.add(eulerXyz(0.1, 1, -1.9, 0, 0.05, 0.0, null).invert(null));
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestRefineTwoViewPinholeRotation method evaluateImperfect.
private void evaluateImperfect(CameraPinhole intrinsic1, CameraPinhole intrinsic2, List<AssociatedPair> pairs) {
var alg = new RefineTwoViewPinholeRotation();
// Apply some constraints. Yes this test isn't exhaustive at all.
alg.assumeUnityAspect = true;
alg.zeroSkew = true;
alg.assumeSameIntrinsics = false;
alg.knownFocalLength = false;
// Focal length and rotation are going to be way off as a test
CameraPinhole found1 = new CameraPinhole(200, 200, 0.0, 530, 530, 1000, 1000);
CameraPinhole found2 = new CameraPinhole(1000, 1000, 0.0, 430, 430, 800, 800);
DMatrixRMaj R = CommonOps_DDRM.identity(3);
alg.converge.maxIterations = 40;
// alg.setVerbose(System.out, null);
assertTrue(alg.refine(pairs, R, found1, found2));
// Should be significantly better
assertTrue(alg.errorAfter * 1e5 <= alg.errorBefore);
// Check constraints
assertEquals(found1.fx, found1.fy);
assertEquals(found2.fx, found2.fy);
assertEquals(0.0, found1.skew);
assertEquals(0.0, found2.skew);
// Based on manual inspection there seems to be redundancy in these equations some place that I've
// not yet dug out. The error is zero but K1 and K2 are significantly different. R is "close"
// very crude test for focal length
assertEquals(intrinsic1.fx, found1.fx, 150);
assertEquals(intrinsic2.fx, found2.fy, 150);
// Compute the number of radians different the two rotations are
DMatrixRMaj diffR = CommonOps_DDRM.multTransA(view1_to_view2.R, R, null);
double angle = ConvertRotation3D_F64.matrixToRodrigues(diffR, null).theta;
assertEquals(0.0, angle, 0.05);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestRefineTwoViewPinholeRotation method imperfectInput_perfectObservations.
/**
* Intrinsic parameters are not correct, but the model will match. No noise added to observations.
*/
@Test
void imperfectInput_perfectObservations() {
CameraPinhole intrinsic1 = new CameraPinhole(400, 400, 0.0, 500, 550, 1000, 1000);
CameraPinhole intrinsic2 = new CameraPinhole(600, 600, 0.0, 400, 440, 800, 800);
List<AssociatedPair> pairs = renderPairs(intrinsic1, intrinsic2, 100, 0.0);
evaluateImperfect(intrinsic1, intrinsic2, pairs);
}
Aggregations