Search in sources :

Example 1 with Equation

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

Example 2 with Equation

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));
}
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 3 with Equation

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));
}
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 Equation

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);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 5 with Equation

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

Aggregations

Equation (org.ejml.equation.Equation)31 DMatrixRMaj (org.ejml.data.DMatrixRMaj)29 Test (org.junit.jupiter.api.Test)28 DMatrix4x4 (org.ejml.data.DMatrix4x4)7 CameraPinhole (boofcv.struct.calib.CameraPinhole)5 Se3_F64 (georegression.struct.se.Se3_F64)5 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)3 ArrayList (java.util.ArrayList)3 DMatrix3x3 (org.ejml.data.DMatrix3x3)3 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Point3D_F64 (georegression.struct.point.Point3D_F64)2 DMatrix2x2 (org.ejml.data.DMatrix2x2)2 SimpleMatrix (org.ejml.simple.SimpleMatrix)2 TrifocalTensor (boofcv.struct.geo.TrifocalTensor)1 Vector3D_F64 (georegression.struct.point.Vector3D_F64)1 DMatrix3 (org.ejml.data.DMatrix3)1