use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method projectiveToMetric.
@Test
void projectiveToMetric() {
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(200, 250, 0.0, 100, 110);
DMatrixRMaj foundK = new DMatrixRMaj(3, 3);
for (int i = 0; i < 50; i++) {
double Tx = rand.nextGaussian();
double Ty = rand.nextGaussian();
double Tz = rand.nextGaussian();
double rotX = rand.nextGaussian();
double rotY = rand.nextGaussian();
double rotZ = rand.nextGaussian();
Se3_F64 m = SpecialEuclideanOps_F64.eulerXyz(Tx, Ty, Tz, rotX, rotY, rotZ, null);
DMatrixRMaj P = PerspectiveOps.createCameraMatrix(m.R, m.T, K, null);
// mess up the scale of P
CommonOps_DDRM.scale(0.9, P, P);
Equation eq = new Equation(P, "P", K, "K");
eq.process("p=[-0.9,0.1,0.7]'").process("H=[K zeros(3,1);-p'*K 1]").process("P=P*H").process("H_inv=inv(H)");
DMatrixRMaj H_inv = eq.lookupDDRM("H_inv");
Se3_F64 found = new Se3_F64();
MultiViewOps.projectiveToMetric(P, H_inv, found, foundK);
assertTrue(MatrixFeatures_DDRM.isEquals(K, foundK, UtilEjml.TEST_F64));
assertEquals(0, m.T.distance(found.T), UtilEjml.TEST_F64);
}
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method projectiveToMetricKnownK.
@Test
void projectiveToMetricKnownK() {
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(200, 250, 0.0, 100, 110);
for (int i = 0; i < 50; i++) {
double Tx = rand.nextGaussian();
double Ty = rand.nextGaussian();
double Tz = rand.nextGaussian();
double rotX = rand.nextGaussian();
double rotY = rand.nextGaussian();
double rotZ = rand.nextGaussian();
Se3_F64 m = SpecialEuclideanOps_F64.eulerXyz(Tx, Ty, Tz, rotX, rotY, rotZ, null);
DMatrixRMaj P = PerspectiveOps.createCameraMatrix(m.R, m.T, K, null);
// mess up the scale of P
CommonOps_DDRM.scale(0.9, P, P);
Equation eq = new Equation(P, "P", K, "K");
eq.process("p=[-0.9,0.1,0.7]'").process("H=[K zeros(3,1);-p'*K 1]").process("P=P*H").process("H_inv=inv(H)");
DMatrixRMaj H_inv = eq.lookupDDRM("H_inv");
Se3_F64 found = new Se3_F64();
assertTrue(MultiViewOps.projectiveToMetricKnownK(P, H_inv, K, found));
assertEquals(0, m.T.distance(found.T), UtilEjml.TEST_F64);
}
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method enforceAbsoluteQuadraticConstraints_negative.
/**
* Give it a valid Q but have the sign be inverted
*/
@Test
void enforceAbsoluteQuadraticConstraints_negative() {
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_neg = new DMatrix4x4();
DConvertMatrixStruct.convert(Q, Q_neg);
// negative and non-standard scale
CommonOps_DDF4.scale(-0.045, Q_neg);
MultiViewOps.enforceAbsoluteQuadraticConstraints(Q_neg, false, false);
// 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_neg.a44), Q_neg);
assertTrue(MatrixFeatures_D.isIdentical(Q, Q_neg, UtilEjml.TEST_F64));
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method canonicalRectifyingHomographyFromKPinf.
@Test
void canonicalRectifyingHomographyFromKPinf() {
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]");
DMatrixRMaj K = eq.lookupDDRM("K");
DMatrixRMaj p = eq.lookupDDRM("p");
Point3D_F64 _p = new Point3D_F64(p.get(0), p.get(1), p.get(2));
// wrong size intentionally
DMatrixRMaj found = new DMatrixRMaj(1, 1);
MultiViewOps.canonicalRectifyingHomographyFromKPinf(K, _p, found);
assertTrue(MatrixFeatures_DDRM.isEquals(eq.lookupDDRM("H"), found, UtilEjml.TEST_F64));
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method multTranA_triple_fixed.
@Test
void multTranA_triple_fixed() {
DMatrix3x3 A = random3x3();
DMatrix3x3 B = random3x3();
DMatrix3x3 C = random3x3();
DMatrix3x3 D = random3x3();
Equation eq = new Equation(A, "A", B, "B", C, "C");
eq.process("D=A'*B*C");
DMatrixRMaj expected = eq.lookupDDRM("D");
PerspectiveOps.multTranA(A, B, C, D);
assertTrue(MatrixFeatures_D.isEquals(expected, D));
}
Aggregations