Search in sources :

Example 11 with Equation

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

the class ChecksMotionNPointHomogenous method createCameraMatrix.

private DMatrixRMaj createCameraMatrix() {
    Equation eq = new Equation();
    eq.process("A=[1,0.1,0.2;0.1,0.9,0.3;0.2,0.3,1.1]");
    eq.process("T=[0.1,0.3,0.5]'");
    eq.process("P=[A,T]");
    return eq.lookupDDRM("P");
}
Also used : Equation(org.ejml.equation.Equation)

Example 12 with Equation

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

the class TestSelfCalibrationGuessAndCheckFocus method setCamera_equation.

/**
 * Compare to an equation written in easy to read code
 */
@Test
void setCamera_equation() {
    SelfCalibrationPraticalGuessAndCheckFocus alg = new SelfCalibrationPraticalGuessAndCheckFocus();
    alg.setCamera(skew, cx, cy, width, height);
    Equation eq = new Equation(skew, "sk", cx, "cx", cy, "cy");
    eq.process("d = sqrt(1000^2 + 800^2)/2");
    eq.process("V=[d sk cx;0 d cy;0 0 1]");
    eq.process("A = inv(V)");
    DMatrixRMaj Vinv = eq.lookupDDRM("A");
    Point2D_F64 a0 = new Point2D_F64(756, 45);
    Point2D_F64 b0 = new Point2D_F64();
    GeometryMath_F64.mult(alg.Vinv, a0, b0);
    Point2D_F64 b1 = new Point2D_F64();
    GeometryMath_F64.mult(Vinv, a0, b1);
    assertEquals(0, b0.distance(b1), UtilEjml.TEST_F64);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 13 with Equation

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

the class TestSelfCalibrationLinearRotationSingle method performTest.

private void performTest(CameraPinhole intrinsic) {
    // compute planes at infinity
    List<Homography2D_F64> homographies = new ArrayList<>();
    for (int i = 0; i < listP.size(); i++) {
        DMatrixRMaj P = listP.get(i);
        Equation eq = new Equation();
        eq.alias(P, "P", planeAtInfinity, "p");
        eq.process("H = P(:,0:2) - P(:,3)*p'");
        Homography2D_F64 H = new Homography2D_F64();
        DConvertMatrixStruct.convert(eq.lookupDDRM("H"), H);
        homographies.add(H);
    }
    SelfCalibrationLinearRotationSingle alg = new SelfCalibrationLinearRotationSingle();
    CameraPinhole found = new CameraPinhole();
    assertTrue(alg.estimate(homographies, found));
    assertEquals(intrinsic.fx, found.fx, UtilEjml.TEST_F64_SQ);
    assertEquals(intrinsic.fy, found.fy, UtilEjml.TEST_F64_SQ);
    assertEquals(intrinsic.cx, found.cx, UtilEjml.TEST_F64_SQ);
    assertEquals(intrinsic.cy, found.cy, UtilEjml.TEST_F64_SQ);
    assertEquals(intrinsic.skew, found.skew, UtilEjml.TEST_F64_SQ);
}
Also used : ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Homography2D_F64(georegression.struct.homography.Homography2D_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole)

Example 14 with Equation

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

the class TestSelfCalibrationLinearRotationSingle method checkFailure.

private void checkFailure() {
    // compute planes at infinity
    List<Homography2D_F64> homographies = new ArrayList<>();
    for (int i = 0; i < listP.size(); i++) {
        DMatrixRMaj P = listP.get(i);
        Equation eq = new Equation();
        eq.alias(P, "P", planeAtInfinity, "p");
        eq.process("H = P(:,0:2) - P(:,3)*p'");
        Homography2D_F64 H = new Homography2D_F64();
        DConvertMatrixStruct.convert(eq.lookupDDRM("H"), H);
        homographies.add(H);
    }
    SelfCalibrationLinearRotationSingle alg = new SelfCalibrationLinearRotationSingle();
    CameraPinhole found = new CameraPinhole();
    assertFalse(alg.estimate(homographies, found));
}
Also used : ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Homography2D_F64(georegression.struct.homography.Homography2D_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole)

Example 15 with Equation

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

the class TestSelfCalibrationLinearRotationSingle method checkLinearSystem.

@Test
void checkLinearSystem() {
    CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 450, 475, 0, 0);
    renderRotationOnly(intrinsic);
    DMatrixRMaj K = new DMatrixRMaj(3, 3);
    PerspectiveOps.pinholeToMatrix(intrinsic, K);
    DMatrixRMaj w = new DMatrixRMaj(3, 3);
    CommonOps_DDRM.multTransB(K, K, w);
    // compute planes at infinity
    List<Homography2D_F64> homographies = new ArrayList<>();
    for (int i = 0; i < listP.size(); i++) {
        // System.out.println("projective "+i);
        DMatrixRMaj P = listP.get(i);
        Equation eq = new Equation();
        eq.alias(P, "P", planeAtInfinity, "p", K, "K", w, "w");
        eq.process("H = P(:,0:2) - P(:,3)*p'");
        // eq.process("w2 = H*w*H'");
        // eq.process("w2 = w2 - w");
        // System.out.println("w");
        // eq.lookupDDRM("w").print();
        // System.out.println("w2");
        // eq.lookupDDRM("w2").print();
        Homography2D_F64 H = new Homography2D_F64();
        DConvertMatrixStruct.convert(eq.lookupDDRM("H"), H);
        homographies.add(H);
    // H.print();
    }
    SelfCalibrationLinearRotationSingle alg = new SelfCalibrationLinearRotationSingle();
    alg.ensureDeterminantOfOne(homographies);
    int N = homographies.size();
    DMatrixRMaj A = new DMatrixRMaj(6 * N, 6);
    DMatrixRMaj X = new DMatrixRMaj(6, 1);
    DMatrixRMaj found = new DMatrixRMaj(A.numRows, 1);
    for (int i = 0; i < homographies.size(); i++) {
        alg.add(i, homographies.get(i), A);
    }
    X.data[0] = w.data[0];
    X.data[1] = w.data[1];
    X.data[2] = w.data[2];
    X.data[3] = w.data[4];
    X.data[4] = w.data[5];
    X.data[5] = w.data[8];
    CommonOps_DDRM.mult(A, X, found);
    assertEquals(0, NormOps_DDRM.normF(found), UtilEjml.TEST_F64);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) ArrayList(java.util.ArrayList) Equation(org.ejml.equation.Equation) CameraPinhole(boofcv.struct.calib.CameraPinhole) Homography2D_F64(georegression.struct.homography.Homography2D_F64) 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