use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.
the class TestHomographyTotalLeastSquares method computePseudo.
@Test
void computePseudo() {
SimpleMatrix P = SimpleMatrix.random_DDRM(10, 2, -1, 1, rand);
SimpleMatrix found = new SimpleMatrix(1, 1);
HomographyTotalLeastSquares.computePseudo(P.getDDRM(), found.getDDRM());
SimpleMatrix expected = P.transpose().mult(P).invert().mult(P.transpose());
assertTrue(expected.isIdentical(found, UtilEjml.TEST_F64));
}
use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.
the class TestHomographyTotalLeastSquares method computePPpX.
@Test
void computePPpX() {
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.computePPpX(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());
assertTrue(expected.isIdentical(found, UtilEjml.TEST_F64));
}
}
use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.
the class TestHomographyTotalLeastSquares method constructA678.
@Test
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]");
HomographyTotalLeastSquares alg = new HomographyTotalLeastSquares();
alg.X1.setTo(P.getDDRM());
alg.X2.setTo(X.getDDRM());
alg.constructA678();
assertTrue(MatrixFeatures_DDRM.isIdentical(eq.lookupDDRM("A"), alg.A, UtilEjml.TEST_F64));
}
use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.
the class TestHomographyTotalLeastSquares method computePPXP.
@Test
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));
}
}
use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.
the class TestPnPLepetitEPnP method extractNullPoints.
@Test
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);
}
Aggregations