Search in sources :

Example 1 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method createTrifocal_CameraMatrix.

/**
 * Check the trifocal tensor using its definition
 */
@Test
public void createTrifocal_CameraMatrix() {
    SimpleMatrix P1 = SimpleMatrix.wrap(PerspectiveOps.createCameraMatrix(worldToCam2.getR(), worldToCam2.getT(), null, null));
    SimpleMatrix P2 = SimpleMatrix.wrap(PerspectiveOps.createCameraMatrix(worldToCam3.getR(), worldToCam3.getT(), null, null));
    TrifocalTensor found = MultiViewOps.createTrifocal(worldToCam2, worldToCam3, null);
    for (int i = 0; i < 3; i++) {
        SimpleMatrix ai = P1.extractVector(false, i);
        SimpleMatrix b4 = P2.extractVector(false, 3);
        SimpleMatrix a4 = P1.extractVector(false, 3);
        SimpleMatrix bi = P2.extractVector(false, i);
        SimpleMatrix expected = ai.mult(b4.transpose()).minus(a4.mult(bi.transpose()));
        assertTrue(MatrixFeatures_DDRM.isIdentical(expected.getDDRM(), found.getT(i), 1e-8));
    }
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) TrifocalTensor(boofcv.struct.geo.TrifocalTensor) Test(org.junit.Test)

Example 2 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method createCameraMatrix.

@Test
public void createCameraMatrix() {
    SimpleMatrix R = SimpleMatrix.random_DDRM(3, 3, -1, 1, rand);
    Vector3D_F64 T = new Vector3D_F64(2, 3, -4);
    SimpleMatrix K = SimpleMatrix.wrap(RandomMatrices_DDRM.triangularUpper(3, 0, -1, 1, rand));
    SimpleMatrix T_ = new SimpleMatrix(3, 1, true, new double[] { T.x, T.y, T.z });
    // test calibrated camera
    DMatrixRMaj found = PerspectiveOps.createCameraMatrix(R.getDDRM(), T, null, null);
    for (int i = 0; i < 3; i++) {
        assertEquals(found.get(i, 3), T_.get(i), 1e-8);
        for (int j = 0; j < 3; j++) {
            assertEquals(found.get(i, j), R.get(i, j), 1e-8);
        }
    }
    // test uncalibrated camera
    found = PerspectiveOps.createCameraMatrix(R.getDDRM(), T, K.getDDRM(), null);
    SimpleMatrix expectedR = K.mult(R);
    SimpleMatrix expectedT = K.mult(T_);
    for (int i = 0; i < 3; i++) {
        assertEquals(found.get(i, 3), expectedT.get(i), 1e-8);
        for (int j = 0; j < 3; j++) {
            assertEquals(found.get(i, j), expectedR.get(i, j), 1e-8);
        }
    }
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 3 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestPnPLepetitEPnP method extractNullPoints.

@Test
public void extractNullPoints() {
    // create a singular matrix
    SimpleMatrix M = SimpleMatrix.wrap(RandomMatrices_DDRM.singular(12, 40, rand, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 0));
    PnPLepetitEPnP alg = new PnPLepetitEPnP();
    alg.numControl = 4;
    alg.extractNullPoints(M.getDDRM());
    // see if the first set of null points is the null space pf M*M
    List<Point3D_F64> l = alg.nullPts[0];
    SimpleMatrix v = new SimpleMatrix(12, 1);
    for (int i = 0; i < 4; i++) {
        Point3D_F64 p = l.get(i);
        v.set(3 * i + 0, p.x);
        v.set(3 * i + 1, p.y);
        v.set(3 * i + 2, p.z);
    }
    SimpleMatrix MM = M.mult(M.transpose());
    SimpleMatrix x = MM.mult(v);
    double mag = x.normF();
    assertEquals(0, mag, 1e-8);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Point3D_F64(georegression.struct.point.Point3D_F64) Test(org.junit.Test)

Example 4 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestHomographyTotalLeastSquares method constructA678.

@Test
public void constructA678() {
    int N = 10;
    SimpleMatrix P = SimpleMatrix.random_DDRM(N, 2, -1, 1, rand);
    SimpleMatrix X = SimpleMatrix.random_DDRM(N, 2, -1, 1, rand);
    Equation eq = new Equation();
    eq.alias(P.copy(), "P", X.copy(), "X", N, "N");
    eq.process("X=-X");
    eq.process("Xd = diag(X(:,0))");
    eq.process("Yd = diag(X(:,1))");
    eq.process("One=ones(N,1)");
    eq.process("Pp=inv(P'*P)*P'");
    eq.process("XP=(X'*P)/N");
    eq.process("top    = [Xd*P-One*XP(0,:)-P*Pp*Xd*P , X(:,0)-P*Pp*X(:,0)]");
    eq.process("bottom = [Yd*P-One*XP(1,:)-P*Pp*Yd*P , X(:,1)-P*Pp*X(:,1)]");
    eq.process("A=[top;bottom]");
    System.out.println();
    HomographyTotalLeastSquares alg = new HomographyTotalLeastSquares();
    alg.X1.set(P.getDDRM());
    alg.X2.set(X.getDDRM());
    alg.constructA678();
    assertTrue(MatrixFeatures_DDRM.isIdentical(eq.lookupDDRM("A"), alg.A, UtilEjml.TEST_F64));
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Equation(org.ejml.equation.Equation) Test(org.junit.Test)

Example 5 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestHomographyTotalLeastSquares method computePPXP.

@Test
public void computePPXP() {
    SimpleMatrix P = SimpleMatrix.random_DDRM(10, 2, -1, 1, rand);
    SimpleMatrix P_plus = SimpleMatrix.random_DDRM(2, 10, -1, 1, rand);
    SimpleMatrix X = SimpleMatrix.random_DDRM(10, 2, -1, 1, rand);
    SimpleMatrix found = new SimpleMatrix(1, 1);
    for (int i = 0; i < 2; i++) {
        HomographyTotalLeastSquares.computePPXP(P.getDDRM(), P_plus.getDDRM(), X.getDDRM(), i, found.getDDRM());
        SimpleMatrix Xx = X.extractVector(false, i);
        SimpleMatrix expected = P.mult(P_plus).mult(Xx.negative().diag()).mult(P);
        assertTrue(expected.isIdentical(found, UtilEjml.TEST_F64));
    }
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Test(org.junit.Test)

Aggregations

SimpleMatrix (org.ejml.simple.SimpleMatrix)156 Test (org.junit.Test)42 Layer (org.gitia.froog.layer.Layer)14 Map (java.util.Map)12 ArrayList (java.util.ArrayList)11 TransferFunction (org.gitia.froog.transferfunction.TransferFunction)10 Tree (edu.stanford.nlp.trees.Tree)9 TwoDimensionalMap (edu.stanford.nlp.util.TwoDimensionalMap)9 List (java.util.List)8 LexicalizedParser (edu.stanford.nlp.parser.lexparser.LexicalizedParser)7 Pair (edu.stanford.nlp.util.Pair)6 EmbeddingExtractor (edu.stanford.nlp.coref.neural.EmbeddingExtractor)5 Embedding (edu.stanford.nlp.neural.Embedding)5 DeepTree (edu.stanford.nlp.trees.DeepTree)5 CoreLabel (edu.stanford.nlp.ling.CoreLabel)4 SimpleTensor (edu.stanford.nlp.neural.SimpleTensor)4 DVModel (edu.stanford.nlp.parser.dvparser.DVModel)4 Logsig (org.gitia.froog.transferfunction.Logsig)4 Ignore (org.junit.Ignore)4 Mention (edu.stanford.nlp.coref.data.Mention)3