use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method rectifyHToAbsoluteQuadratic.
@Test
void rectifyHToAbsoluteQuadratic() {
Equation eq = new Equation();
eq.process("K=[300 1 50;0 310 60; 0 0 1]");
eq.process("p=rand(3,1)");
eq.process("u=-p'*K");
eq.process("H=[K [0;0;0]; u 1]");
eq.process("Q=H*diag([1 1 1 0])*H'");
DMatrixRMaj Q = eq.lookupDDRM("Q");
DMatrixRMaj H = eq.lookupDDRM("H");
DMatrixRMaj foundQ = new DMatrixRMaj(4, 4);
MultiViewOps.rectifyHToAbsoluteQuadratic(H, foundQ);
assertTrue(MatrixFeatures_D.isIdentical(Q, foundQ, UtilEjml.TEST_F64));
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method decomposeAbsDualQuadratic.
@Test
void decomposeAbsDualQuadratic() {
Equation eq = new Equation();
eq.process("K=[300 1 50;0 310 60; 0 0 1]");
eq.process("w=K*K'");
eq.process("p=rand(3,1)");
eq.process("u=-p'*K");
eq.process("H=[K [0;0;0]; u 1]");
eq.process("Q=H*diag([1 1 1 0])*H'");
DMatrixRMaj Q = eq.lookupDDRM("Q");
DMatrix4x4 Q_in = new DMatrix4x4();
DConvertMatrixStruct.convert(Q, Q_in);
CommonOps_DDF4.scale(0.0394, Q_in);
DMatrix3x3 w = new DMatrix3x3();
DMatrix3 p = new DMatrix3();
assertTrue(MultiViewOps.decomposeAbsDualQuadratic(Q_in, w, p));
assertTrue(MatrixFeatures_D.isIdentical(eq.lookupDDRM("w"), w, UtilEjml.TEST_F64));
assertTrue(MatrixFeatures_D.isIdentical(eq.lookupDDRM("p"), p, UtilEjml.TEST_F64));
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method absoluteQuadraticToH.
@Test
void absoluteQuadraticToH() {
Equation eq = new Equation();
eq.process("K=[300 1 50;0 310 60; 0 0 1]");
eq.process("p=rand(3,1)");
eq.process("u=-p'*K");
eq.process("H=[K [0;0;0]; u 1]");
eq.process("Q=H*diag([1 1 1 0])*H'");
DMatrixRMaj Q = eq.lookupDDRM("Q");
DMatrix4x4 Q_in = new DMatrix4x4();
DConvertMatrixStruct.convert(Q, Q_in);
DMatrixRMaj H = eq.lookupDDRM("H");
DMatrixRMaj foundH = new DMatrixRMaj(4, 4);
assertTrue(MultiViewOps.absoluteQuadraticToH(Q_in, foundH));
assertTrue(MatrixFeatures_D.isIdentical(H, foundH, UtilEjml.TEST_F64));
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method intrinsicFromAbsoluteQuadratic.
@Test
void intrinsicFromAbsoluteQuadratic() {
Equation eq = new Equation();
eq.process("K1=[300 1 50;0 310 60; 0 0 1]");
eq.process("K2=[310 1 75;0 310 60; 0 0 1]");
eq.process("p=rand(3,1)");
eq.process("u=-p'*K1");
eq.process("H=[K1 [0;0;0]; u 1]");
// very simplistic P
eq.process("P=K2*[eye(3) [1;2;3]]");
// back to projective
eq.process("P=P*inv(H)");
eq.process("Q=-1.1*H*diag([1 1 1 0])*H'");
DMatrixRMaj P = eq.lookupDDRM("P");
DMatrixRMaj Q = eq.lookupDDRM("Q");
CameraPinhole intrinsic = new CameraPinhole();
MultiViewOps.intrinsicFromAbsoluteQuadratic(Q, P, intrinsic);
assertEquals(310, intrinsic.fx, 1e-6);
assertEquals(310, intrinsic.fy, 1e-6);
assertEquals(75, intrinsic.cx, 1e-6);
assertEquals(60, intrinsic.cy, 1e-6);
assertEquals(1, intrinsic.skew, 1e-6);
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method enforceAbsoluteQuadraticConstraints_zeros.
/**
* Give it a valid Q but request that zeros be constrained
*/
@Test
void enforceAbsoluteQuadraticConstraints_zeros() {
Equation eq = new Equation();
eq.process("K=[300 1 50;0 310 60; 0 0 1]");
eq.process("p=rand(3,1)");
eq.process("H=[K [0;0;0]; -p'*K 1]");
eq.process("Q=H*diag([1 1 1 0])*H'");
DMatrixRMaj Q = eq.lookupDDRM("Q");
DMatrix4x4 Q_in = new DMatrix4x4();
DConvertMatrixStruct.convert(Q, Q_in);
assertTrue(MultiViewOps.enforceAbsoluteQuadraticConstraints(Q_in, true, true));
eq.process("K=[300 0 0;0 310 0; 0 0 1]");
eq.process("H=[K [0;0;0]; -p'*K 1]");
eq.process("Q=H*diag([1 1 1 0])*H'");
// change scale so that the test tolerance is reasonable
CommonOps_DDRM.scale(1.0 / Math.abs(Q.get(3, 3)), Q);
CommonOps_DDF4.scale(1.0 / Math.abs(Q_in.a44), Q_in);
assertTrue(MatrixFeatures_D.isIdentical(Q, Q_in, UtilEjml.TEST_F64));
}
Aggregations