use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearRotationSingle method two_axis.
@Test
void two_axis() {
CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 450, 475, 0, 0);
renderRotateTwoAxis(intrinsic);
performTest(intrinsic);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearRotationSingle method checkFailure.
private void checkFailure() {
// compute planes at infinity
List<Homography2D_F64> homographies = new ArrayList<>();
for (int i = 0; i < listP.size(); i++) {
DMatrixRMaj P = listP.get(i);
Equation eq = new Equation();
eq.alias(P, "P", planeAtInfinity, "p");
eq.process("H = P(:,0:2) - P(:,3)*p'");
Homography2D_F64 H = new Homography2D_F64();
DConvertMatrixStruct.convert(eq.lookupDDRM("H"), H);
homographies.add(H);
}
SelfCalibrationLinearRotationSingle alg = new SelfCalibrationLinearRotationSingle();
CameraPinhole found = new CameraPinhole();
assertFalse(alg.estimate(homographies, found));
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearRotationSingle method checkLinearSystem.
@Test
void checkLinearSystem() {
CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 450, 475, 0, 0);
renderRotationOnly(intrinsic);
DMatrixRMaj K = new DMatrixRMaj(3, 3);
PerspectiveOps.pinholeToMatrix(intrinsic, K);
DMatrixRMaj w = new DMatrixRMaj(3, 3);
CommonOps_DDRM.multTransB(K, K, w);
// compute planes at infinity
List<Homography2D_F64> homographies = new ArrayList<>();
for (int i = 0; i < listP.size(); i++) {
// System.out.println("projective "+i);
DMatrixRMaj P = listP.get(i);
Equation eq = new Equation();
eq.alias(P, "P", planeAtInfinity, "p", K, "K", w, "w");
eq.process("H = P(:,0:2) - P(:,3)*p'");
// eq.process("w2 = H*w*H'");
// eq.process("w2 = w2 - w");
// System.out.println("w");
// eq.lookupDDRM("w").print();
// System.out.println("w2");
// eq.lookupDDRM("w2").print();
Homography2D_F64 H = new Homography2D_F64();
DConvertMatrixStruct.convert(eq.lookupDDRM("H"), H);
homographies.add(H);
// H.print();
}
SelfCalibrationLinearRotationSingle alg = new SelfCalibrationLinearRotationSingle();
alg.ensureDeterminantOfOne(homographies);
int N = homographies.size();
DMatrixRMaj A = new DMatrixRMaj(6 * N, 6);
DMatrixRMaj X = new DMatrixRMaj(6, 1);
DMatrixRMaj found = new DMatrixRMaj(A.numRows, 1);
for (int i = 0; i < homographies.size(); i++) {
alg.add(i, homographies.get(i), A);
}
X.data[0] = w.data[0];
X.data[1] = w.data[1];
X.data[2] = w.data[2];
X.data[3] = w.data[4];
X.data[4] = w.data[5];
X.data[5] = w.data[8];
CommonOps_DDRM.mult(A, X, found);
assertEquals(0, NormOps_DDRM.normF(found), UtilEjml.TEST_F64);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearRotationSingle method one_axis.
/**
* One axis rotation will fail
*/
@Test
void one_axis() {
CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 450, 475, 0, 0);
renderRotateOneAxis(intrinsic);
checkFailure();
}
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);
}
Aggregations