use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class ChecksMotionNPointHomogenous method createCameraMatrix.
private DMatrixRMaj createCameraMatrix() {
Equation eq = new Equation();
eq.process("A=[1,0.1,0.2;0.1,0.9,0.3;0.2,0.3,1.1]");
eq.process("T=[0.1,0.3,0.5]'");
eq.process("P=[A,T]");
return eq.lookupDDRM("P");
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationGuessAndCheckFocus method setCamera_equation.
/**
* Compare to an equation written in easy to read code
*/
@Test
void setCamera_equation() {
SelfCalibrationPraticalGuessAndCheckFocus alg = new SelfCalibrationPraticalGuessAndCheckFocus();
alg.setCamera(skew, cx, cy, width, height);
Equation eq = new Equation(skew, "sk", cx, "cx", cy, "cy");
eq.process("d = sqrt(1000^2 + 800^2)/2");
eq.process("V=[d sk cx;0 d cy;0 0 1]");
eq.process("A = inv(V)");
DMatrixRMaj Vinv = eq.lookupDDRM("A");
Point2D_F64 a0 = new Point2D_F64(756, 45);
Point2D_F64 b0 = new Point2D_F64();
GeometryMath_F64.mult(alg.Vinv, a0, b0);
Point2D_F64 b1 = new Point2D_F64();
GeometryMath_F64.mult(Vinv, a0, b1);
assertEquals(0, b0.distance(b1), UtilEjml.TEST_F64);
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestSelfCalibrationLinearRotationSingle method performTest.
private void performTest(CameraPinhole intrinsic) {
// 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();
assertTrue(alg.estimate(homographies, found));
assertEquals(intrinsic.fx, found.fx, UtilEjml.TEST_F64_SQ);
assertEquals(intrinsic.fy, found.fy, UtilEjml.TEST_F64_SQ);
assertEquals(intrinsic.cx, found.cx, UtilEjml.TEST_F64_SQ);
assertEquals(intrinsic.cy, found.cy, UtilEjml.TEST_F64_SQ);
assertEquals(intrinsic.skew, found.skew, UtilEjml.TEST_F64_SQ);
}
use of org.ejml.equation.Equation 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 org.ejml.equation.Equation 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);
}
Aggregations