use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestTriangulateProjectiveLinearDLT method triangulate_projective_noise.
/**
* Add a tinny bit of noise and see if it blows up
*/
@Test
void triangulate_projective_noise() {
createScene();
TriangulateProjectiveLinearDLT alg = new TriangulateProjectiveLinearDLT();
Point4D_F64 foundX = new Point4D_F64();
obsPixels.get(0).x += 0.01;
obsPixels.get(0).y -= 0.01;
alg.triangulate(obsPixels, cameraMatrices, foundX);
// project the found coordinate back on to each image
Point2D_F64 foundPixel = new Point2D_F64();
for (int i = 0; i < cameraMatrices.size(); i++) {
DMatrixRMaj P = cameraMatrices.get(i);
Point2D_F64 expected = obsPixels.get(i);
GeometryMath_F64.mult(P, foundX, foundPixel);
assertEquals(0, expected.distance(foundPixel), 0.03);
}
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class CommonTrifocalChecks method checkTrifocalWithConstraint.
public void checkTrifocalWithConstraint(TrifocalTensor tensor, double tol) {
for (int i = 0; i < observations.size(); i++) {
AssociatedTriple o = observations.get(i);
DMatrixRMaj c = MultiViewOps.constraint(tensor, o.p1, o.p2, o.p3, null);
double v = NormOps_DDRM.normF(c) / (c.numCols * c.numRows);
assertEquals(0, v, tol);
}
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestRefineThreeViewProjectiveGeometric method perfect.
@Test
void perfect() {
RefineThreeViewProjectiveGeometric alg = new RefineThreeViewProjectiveGeometric();
List<AssociatedTriple> originalPixels = new ArrayList<>();
for (int i = 0; i < observationsPixels.size(); i++) {
originalPixels.add(observationsPixels.get(i).copy());
}
DMatrixRMaj originalP2 = P2.copy();
DMatrixRMaj originalP3 = P3.copy();
alg.refine(observations, P2, P3);
// make sure there were no changes
for (int i = 0; i < originalPixels.size(); i++) {
assertTrue(originalPixels.get(i).isIdentical(observationsPixels.get(i), UtilEjml.TEST_F64));
}
assertTrue(MatrixFeatures_DDRM.isIdentical(originalP2, P2, 1e-3));
assertTrue(MatrixFeatures_DDRM.isIdentical(originalP3, P3, 1e-3));
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestTrifocalExtractGeometries method extractFundmental.
@Test
void extractFundmental() {
TrifocalExtractGeometries alg = new TrifocalExtractGeometries();
DMatrixRMaj found2 = new DMatrixRMaj(3, 3);
DMatrixRMaj found3 = new DMatrixRMaj(3, 3);
for (int trial = 0; trial < 5; trial++) {
createRandomScenario(false);
TrifocalTensor input = tensor.copy();
alg.setTensor(input);
alg.extractFundmental(found2, found3);
// make sure the input was not modified
for (int i = 0; i < 3; i++) assertTrue(MatrixFeatures_DDRM.isIdentical(tensor.getT(i), input.getT(i), 1e-8));
CommonOps_DDRM.scale(1.0 / CommonOps_DDRM.elementMaxAbs(found2), found2);
CommonOps_DDRM.scale(1.0 / CommonOps_DDRM.elementMaxAbs(found3), found3);
Point3D_F64 X = new Point3D_F64(0.1, 0.05, 2);
// remember the first view is assumed to have a projection matrix of [I|0]
Point2D_F64 x1 = PerspectiveOps.renderPixel(new Se3_F64(), X, null);
Point2D_F64 x2 = PerspectiveOps.renderPixel(worldToCam2, K, X, null);
Point2D_F64 x3 = PerspectiveOps.renderPixel(worldToCam3, K, X, null);
assertEquals(0, MultiViewOps.constraint(found2, x1, x2), 1e-8);
assertEquals(0, MultiViewOps.constraint(found3, x1, x3), 1e-8);
}
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestTrifocalLinearPoint7 method fullTest.
void fullTest(boolean planar) {
createSceneObservations(planar);
TrifocalLinearPoint7 alg = new TrifocalLinearPoint7();
assertTrue(alg.process(observationsPixels, found));
// validate the solution by using a constraint
for (AssociatedTriple a : observationsPixels) {
DMatrixRMaj A = MultiViewOps.constraint(found, a.p1, a.p2, a.p3, null);
assertEquals(0, NormOps_DDRM.normF(A), 1e-6);
}
// see if epipoles are zero
for (int i = 0; i < 3; i++) {
DMatrixRMaj T = found.getT(i);
// sanity check that it just isn't zero
assertTrue(NormOps_DDRM.normF(T) > 1e-7);
// rank should be 2
assertEquals(2, SingularOps_DDRM.rank(T, UtilEjml.TEST_F64));
}
}
Aggregations