use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestRefineTwoViewPinholeRotation method perfectInput.
/**
* Give it perfect input and see if it screws things up
*/
@Test
void perfectInput() {
CameraPinhole intrinsic1 = new CameraPinhole(400, 410, 0.1, 500, 550, 1000, 1000);
CameraPinhole intrinsic2 = new CameraPinhole(600, 550, 0.02, 400, 440, 800, 800);
List<AssociatedPair> pairs = renderPairs(intrinsic1, intrinsic2, 50, 0.0);
var alg = new RefineTwoViewPinholeRotation();
// turn off all assumptions
alg.assumeUnityAspect = false;
alg.zeroSkew = false;
alg.assumeSameIntrinsics = false;
CameraPinhole found1 = new CameraPinhole(intrinsic1);
CameraPinhole found2 = new CameraPinhole(intrinsic2);
DMatrixRMaj R = view1_to_view2.R.copy();
assertTrue(alg.refine(pairs, R, found1, found2));
// Score shouldn't get worse, but since the input is perfect it might not get better
assertTrue(alg.errorAfter <= alg.errorBefore);
// should be very very similar
assertTrue(found1.isEquals(intrinsic1, 1e-6));
assertTrue(found2.isEquals(intrinsic2, 1e-6));
assertTrue(MatrixFeatures_DDRM.isIdentical(view1_to_view2.R, R, 1e-6));
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearDualQuadratic method geometry_no_rotation.
@Test
void geometry_no_rotation() {
CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 0, 0, 0, 0);
renderTranslationOnly(intrinsic);
SelfCalibrationLinearDualQuadratic alg = new SelfCalibrationLinearDualQuadratic(false);
addProjectives(alg);
assertEquals(GeometricResult.GEOMETRY_POOR, alg.solve());
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearDualQuadratic method solve_ZeroCP_ZSkew.
@Test
void solve_ZeroCP_ZSkew() {
List<CameraPinhole> intrinsics = new ArrayList<>();
for (int i = 0; i < 4; i++) {
intrinsics.add(new CameraPinhole(400 + i * 5, 420, 0, 0, 0, 0, 0));
}
checkSolve(intrinsics, false, true, 4);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearDualQuadratic method geometry_no_translation.
@Test
void geometry_no_translation() {
CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 0, 0, 0, 0);
renderRotationOnly(intrinsic);
SelfCalibrationLinearDualQuadratic alg = new SelfCalibrationLinearDualQuadratic(false);
addProjectives(alg);
assertEquals(GeometricResult.GEOMETRY_POOR, alg.solve());
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearDualQuadratic method solveWithTrificalInput.
/**
* Create a trifocal tensor, extract camera matrices, and see if it can find the solution
*/
@Test
void solveWithTrificalInput() {
CameraPinhole intrinsic = new CameraPinhole(500, 500, 0, 0, 0, 0, 0);
List<CameraPinhole> intrinsics = new ArrayList<>();
for (int i = 0; i < 3; i++) {
intrinsics.add(intrinsic);
}
renderGood(intrinsics);
List<AssociatedTriple> obs = new ArrayList<>();
for (int i = 0; i < cloud.size(); i++) {
Point3D_F64 X = cloud.get(i);
AssociatedTriple t = new AssociatedTriple();
t.p1 = PerspectiveOps.renderPixel(listCameraToWorld.get(0), intrinsic, X, null);
t.p2 = PerspectiveOps.renderPixel(listCameraToWorld.get(1), intrinsic, X, null);
t.p3 = PerspectiveOps.renderPixel(listCameraToWorld.get(2), intrinsic, X, null);
obs.add(t);
}
ConfigTrifocal config = new ConfigTrifocal();
config.which = EnumTrifocal.LINEAR_7;
Estimate1ofTrifocalTensor estimate = FactoryMultiView.trifocal_1(config);
TrifocalTensor tensor = new TrifocalTensor();
assertTrue(estimate.process(obs, tensor));
DMatrixRMaj P1 = CommonOps_DDRM.identity(3, 4);
DMatrixRMaj P2 = new DMatrixRMaj(3, 4);
DMatrixRMaj P3 = new DMatrixRMaj(3, 4);
MultiViewOps.trifocalToCameraMatrices(tensor, P2, P3);
SelfCalibrationLinearDualQuadratic alg = new SelfCalibrationLinearDualQuadratic(1.0);
alg.addCameraMatrix(P1);
alg.addCameraMatrix(P2);
alg.addCameraMatrix(P3);
assertEquals(GeometricResult.SUCCESS, alg.solve());
FastAccess<Intrinsic> found = alg.getIntrinsics();
assertEquals(3, found.size());
for (int i = 0; i < found.size(); i++) {
Intrinsic f = found.get(i);
assertEquals(500, f.fx, UtilEjml.TEST_F64_SQ);
assertEquals(500, f.fy, UtilEjml.TEST_F64_SQ);
assertEquals(0, f.skew, UtilEjml.TEST_F64_SQ);
}
}
Aggregations