Search in sources :

Example 81 with DMatrixRMaj

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);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Point4D_F64(georegression.struct.point.Point4D_F64) Test(org.junit.jupiter.api.Test)

Example 82 with DMatrixRMaj

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);
    }
}
Also used : AssociatedTriple(boofcv.struct.geo.AssociatedTriple) DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 83 with DMatrixRMaj

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));
}
Also used : AssociatedTriple(boofcv.struct.geo.AssociatedTriple) ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.jupiter.api.Test)

Example 84 with DMatrixRMaj

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);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) TrifocalTensor(boofcv.struct.geo.TrifocalTensor) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 85 with DMatrixRMaj

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));
    }
}
Also used : AssociatedTriple(boofcv.struct.geo.AssociatedTriple) DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Aggregations

DMatrixRMaj (org.ejml.data.DMatrixRMaj)454 Test (org.junit.jupiter.api.Test)210 Se3_F64 (georegression.struct.se.Se3_F64)107 Point2D_F64 (georegression.struct.point.Point2D_F64)87 Point3D_F64 (georegression.struct.point.Point3D_F64)68 ArrayList (java.util.ArrayList)55 Vector3D_F64 (georegression.struct.point.Vector3D_F64)54 AssociatedPair (boofcv.struct.geo.AssociatedPair)38 CameraPinhole (boofcv.struct.calib.CameraPinhole)32 Equation (org.ejml.equation.Equation)29 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)25 Point4D_F64 (georegression.struct.point.Point4D_F64)19 StringReader (java.io.StringReader)16 Test (org.junit.Test)15 AssociatedTriple (boofcv.struct.geo.AssociatedTriple)12 TrifocalTensor (boofcv.struct.geo.TrifocalTensor)11 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)10 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)10 BufferedImage (java.awt.image.BufferedImage)10 SceneStructureProjective (boofcv.abst.geo.bundle.SceneStructureProjective)9