Search in sources :

Example 16 with Equation

use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.

the class TestPnPInfinitesimalPlanePoseEstimation method constructR.

@Test
void constructR() {
    Equation eq = new Equation();
    eq.process("R_v=randn(3,3)");
    eq.process("R22=[1 2;3 4]");
    eq.process("c=[1.1;2.1]");
    eq.process("a=3.1");
    eq.process("b=[-0.4;0.2]");
    eq.process("R1=R_v*[R22 c;b' a]");
    eq.process("R2=R_v*[R22, -c;-b', a]");
    DMatrixRMaj found = new DMatrixRMaj(3, 3);
    DMatrixRMaj R_v = eq.lookupDDRM("R_v");
    DMatrix2x2 R22 = new DMatrix2x2();
    DConvertMatrixStruct.convert(eq.lookupDDRM("R22"), R22);
    Vector3D_F64 ca = new Vector3D_F64(1.1, 2.1, 3.1);
    PnPInfinitesimalPlanePoseEstimation.constructR(found, R_v, R22, -0.4, 0.2, ca, 1, new DMatrixRMaj(3, 3));
    assertTrue(MatrixFeatures_DDRM.isIdentical(eq.lookupDDRM("R1"), found, UtilEjml.TEST_F64));
    PnPInfinitesimalPlanePoseEstimation.constructR(found, R_v, R22, -0.4, 0.2, ca, -1, new DMatrixRMaj(3, 3));
    assertTrue(MatrixFeatures_DDRM.isIdentical(eq.lookupDDRM("R2"), found, UtilEjml.TEST_F64));
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrix2x2(org.ejml.data.DMatrix2x2) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 17 with Equation

use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.

the class TestPnPInfinitesimalPlanePoseEstimation method compute_Rv.

@Test
void compute_Rv() {
    Equation eq = new Equation();
    eq.process("v=[1.1,0.5]'");
    eq.process("t=normF(v)");
    eq.process("s=normF([v',1]')");
    eq.process("cosT=1.0/s");
    eq.process("sinT=sqrt(1-1.0/s^2)");
    eq.process("Kx=(1.0/t)*[[0 0;0 0] v;-v' 0]");
    eq.process("R_v = eye(3) + sinT*Kx + (1.0-cosT)*Kx*Kx");
    PnPInfinitesimalPlanePoseEstimation alg = new PnPInfinitesimalPlanePoseEstimation();
    DMatrixRMaj V = eq.lookupDDRM("v");
    alg.v1 = V.get(0);
    alg.v2 = V.get(1);
    alg.compute_Rv();
    DMatrixRMaj expected_R_v = eq.lookupDDRM("R_v");
    assertTrue(MatrixFeatures_DDRM.isEquals(expected_R_v, alg.R_v, UtilEjml.TEST_F64));
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 18 with Equation

use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.

the class TestPnPInfinitesimalPlanePoseEstimation method compute_B.

@Test
void compute_B() {
    Equation eq = new Equation();
    eq.process("v=[1.1,0.5]'");
    eq.process("R_v=[1,2,3;4,5,6;7,8,9]'");
    eq.process("B=[eye(2),-v]*R_v");
    DMatrixRMaj v = eq.lookupDDRM("v");
    DMatrixRMaj R_v = eq.lookupDDRM("R_v");
    DMatrixRMaj expected = eq.lookupDDRM("B");
    double v1 = v.get(0);
    double v2 = v.get(1);
    DMatrix2x2 B = new DMatrix2x2();
    PnPInfinitesimalPlanePoseEstimation.compute_B(B, R_v, v1, v2);
    assertEquals(expected.get(0, 0), B.a11, UtilEjml.TEST_F64);
    assertEquals(expected.get(0, 1), B.a12, UtilEjml.TEST_F64);
    assertEquals(expected.get(1, 0), B.a21, UtilEjml.TEST_F64);
    assertEquals(expected.get(1, 1), B.a22, UtilEjml.TEST_F64);
}
Also used : DMatrix2x2(org.ejml.data.DMatrix2x2) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 19 with Equation

use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.

the class TestHomographyTotalLeastSquares method backsubstitution0134.

@Test
void backsubstitution0134() {
    int N = 10;
    SimpleMatrix Pp = SimpleMatrix.random_DDRM(2, N, -1, 1, rand);
    SimpleMatrix P = SimpleMatrix.random_DDRM(N, 2, -1, 1, rand);
    SimpleMatrix X = SimpleMatrix.random_DDRM(N, 2, -1, 1, rand);
    double[] H = new double[9];
    H[6] = 0.4;
    H[7] = 0.8;
    H[8] = -0.3;
    Equation eq = new Equation();
    eq.alias(P.copy(), "P", Pp.copy(), "Pp", X.copy(), "X", N, "N");
    eq.process("H=[0.4;0.8;-0.3]");
    eq.process("Ax = -Pp*diag(-X(:,0))*[P,ones(N,1)]*H");
    eq.process("Ay = -Pp*diag(-X(:,1))*[P,ones(N,1)]*H");
    HomographyTotalLeastSquares.backsubstitution0134(Pp.getMatrix(), P.getMatrix(), X.getMatrix(), H);
    DMatrixRMaj Ax = eq.lookupDDRM("Ax");
    DMatrixRMaj Ay = eq.lookupDDRM("Ay");
    assertEquals(Ax.data[0], H[0], UtilEjml.TEST_F64);
    assertEquals(Ax.data[1], H[1], UtilEjml.TEST_F64);
    assertEquals(Ay.data[0], H[3], UtilEjml.TEST_F64);
    assertEquals(Ay.data[1], H[4], UtilEjml.TEST_F64);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 20 with Equation

use of org.ejml.equation.Equation 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)

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