use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestDecomposeProjectiveToMetric method projectiveToMetric.
@Test
void projectiveToMetric() {
var alg = new DecomposeProjectiveToMetric();
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(200, 250, 0.0, 100, 110);
DMatrixRMaj foundK = new DMatrixRMaj(3, 3);
for (int i = 0; i < 50; i++) {
double Tx = rand.nextGaussian();
double Ty = rand.nextGaussian();
double Tz = rand.nextGaussian();
double rotX = rand.nextGaussian();
double rotY = rand.nextGaussian();
double rotZ = rand.nextGaussian();
Se3_F64 m = SpecialEuclideanOps_F64.eulerXyz(Tx, Ty, Tz, rotX, rotY, rotZ, null);
DMatrixRMaj P = PerspectiveOps.createCameraMatrix(m.R, m.T, K, null);
// mess up the scale of P
CommonOps_DDRM.scale(0.9, P, P);
Equation eq = new Equation(P, "P", K, "K");
eq.process("p=[-0.9,0.1,0.7]'").process("H=[K zeros(3,1);-p'*K 1]").process("P=P*H").process("H_inv=inv(H)");
DMatrixRMaj H_inv = eq.lookupDDRM("H_inv");
Se3_F64 found = new Se3_F64();
assertTrue(alg.projectiveToMetric(P, H_inv, found, foundK));
assertTrue(MatrixFeatures_DDRM.isEquals(K, foundK, UtilEjml.TEST_F64));
assertEquals(0, m.T.distance(found.T), UtilEjml.TEST_F64);
}
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestDecomposeProjectiveToMetric method projectiveToMetricKnownK.
@Test
void projectiveToMetricKnownK() {
var alg = new DecomposeProjectiveToMetric();
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(200, 250, 0.0, 100, 110);
for (int i = 0; i < 50; i++) {
double Tx = rand.nextGaussian();
double Ty = rand.nextGaussian();
double Tz = rand.nextGaussian();
double rotX = rand.nextGaussian();
double rotY = rand.nextGaussian();
double rotZ = rand.nextGaussian();
Se3_F64 m = SpecialEuclideanOps_F64.eulerXyz(Tx, Ty, Tz, rotX, rotY, rotZ, null);
DMatrixRMaj P = PerspectiveOps.createCameraMatrix(m.R, m.T, K, null);
// mess up the scale of P
CommonOps_DDRM.scale(0.9, P, P);
Equation eq = new Equation(P, "P", K, "K");
eq.process("p=[-0.9,0.1,0.7]'").process("H=[K zeros(3,1);-p'*K 1]").process("P=P*H").process("H_inv=inv(H)");
DMatrixRMaj H_inv = eq.lookupDDRM("H_inv");
Se3_F64 found = new Se3_F64();
assertTrue(alg.projectiveToMetricKnownK(P, H_inv, K, found));
assertEquals(0, m.T.distance(found.T), UtilEjml.TEST_F64);
}
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method multTranA_triple_dense.
@Test
void multTranA_triple_dense() {
DMatrixRMaj A = RandomMatrices_DDRM.rectangle(3, 3, rand);
DMatrixRMaj B = RandomMatrices_DDRM.rectangle(3, 3, rand);
DMatrixRMaj C = RandomMatrices_DDRM.rectangle(3, 3, rand);
DMatrixRMaj D = RandomMatrices_DDRM.rectangle(3, 3, rand);
Equation eq = new Equation(A, "A", B, "B", C, "C");
eq.process("D=A'*B*C");
DMatrixRMaj expected = eq.lookupDDRM("D");
PerspectiveOps.multTranA(A, B, C, D);
assertTrue(MatrixFeatures_DDRM.isEquals(expected, D, UtilEjml.TEST_F64));
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method multTranC_triple_fixed.
@Test
void multTranC_triple_fixed() {
DMatrix3x3 A = random3x3();
DMatrix3x3 B = random3x3();
DMatrix3x3 C = random3x3();
DMatrix3x3 D = random3x3();
Equation eq = new Equation(A, "A", B, "B", C, "C");
eq.process("D=A*B*C'");
DMatrixRMaj expected = eq.lookupDDRM("D");
PerspectiveOps.multTranC(A, B, C, D);
assertTrue(MatrixFeatures_D.isEquals(expected, D));
}
use of org.ejml.equation.Equation 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));
}
Aggregations