Search in sources :

Example 1 with DMatrix4x4

use of org.ejml.data.DMatrix4x4 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));
}
Also used : DMatrix3(org.ejml.data.DMatrix3) DMatrixRMaj(org.ejml.data.DMatrixRMaj) DMatrix4x4(org.ejml.data.DMatrix4x4) Equation(org.ejml.equation.Equation) DMatrix3x3(org.ejml.data.DMatrix3x3) Test(org.junit.jupiter.api.Test)

Example 2 with DMatrix4x4

use of org.ejml.data.DMatrix4x4 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));
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) DMatrix4x4(org.ejml.data.DMatrix4x4) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 3 with DMatrix4x4

use of org.ejml.data.DMatrix4x4 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));
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) DMatrix4x4(org.ejml.data.DMatrix4x4) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 4 with DMatrix4x4

use of org.ejml.data.DMatrix4x4 in project BoofCV by lessthanoptimal.

the class TestDecomposeAbsoluteDualQuadratic method recomputeQ.

@Test
void recomputeQ() {
    Equation eq = new Equation();
    eq.process("k = [300 3, 204;0 230 400; 0 0 1]").process("w = k*k'").process("p=[2.1;0.4;-0.3]").process("Q=[w , -w*p;-p'*w, p'*w*p]");
    DecomposeAbsoluteDualQuadratic alg = new DecomposeAbsoluteDualQuadratic();
    DConvertMatrixStruct.convert(eq.lookupDDRM("k"), alg.getK());
    DConvertMatrixStruct.convert(eq.lookupDDRM("p"), alg.getP());
    DMatrix4x4 found = new DMatrix4x4();
    alg.recomputeQ(found);
    DMatrixRMaj Q = eq.lookupDDRM("Q");
    assertTrue(MatrixFeatures_D.isIdentical(Q, found, UtilEjml.TEST_F64));
}
Also used : DMatrix4x4(org.ejml.data.DMatrix4x4) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 5 with DMatrix4x4

use of org.ejml.data.DMatrix4x4 in project BoofCV by lessthanoptimal.

the class TestDecomposeAbsoluteDualQuadratic method decompose.

@Test
void decompose() {
    Equation eq = new Equation(K, "K");
    DMatrixRMaj Q = eq.process("I=diag([1,1,1,0])").process("p=[2.1;0.4;-0.3]").process("H=[K [0;0;0];-p'*K 1]").process("Q=H*I*H'").process(// change scale of Q to make it more interesting
    "Q=Q*1e-3").lookupDDRM("Q");
    DMatrixRMaj w = eq.process("w=Q(0:2,0:2)").lookupDDRM("w");
    DMatrixRMaj p = eq.process("p=-inv(w)*Q(0:2,3)").lookupDDRM("p");
    DMatrix4x4 _Q = new DMatrix4x4();
    DConvertMatrixStruct.convert(Q, _Q);
    DecomposeAbsoluteDualQuadratic alg = new DecomposeAbsoluteDualQuadratic();
    assertTrue(alg.decompose(_Q));
    CommonOps_DDRM.scale(1.0 / w.get(2, 2), w);
    assertTrue(MatrixFeatures_D.isIdentical(w, alg.getW(), UtilEjml.TEST_F64));
    assertTrue(MatrixFeatures_D.isIdentical(p, alg.getP(), UtilEjml.TEST_F64));
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) DMatrix4x4(org.ejml.data.DMatrix4x4) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Aggregations

DMatrix4x4 (org.ejml.data.DMatrix4x4)7 DMatrixRMaj (org.ejml.data.DMatrixRMaj)7 Equation (org.ejml.equation.Equation)7 Test (org.junit.jupiter.api.Test)7 DMatrix3 (org.ejml.data.DMatrix3)1 DMatrix3x3 (org.ejml.data.DMatrix3x3)1