Search in sources :

Example 1 with NormalizationPoint2D

use of boofcv.alg.geo.NormalizationPoint2D in project BoofCV by lessthanoptimal.

the class TestEnforceTrifocalGeometry method perfectInput.

/**
 * Give it a set of perfect inputs and see if it computes a valid trifocal tensor
 */
@Test
public void perfectInput() {
    // create linear constraint matrix
    TrifocalLinearPoint7 constructA = new TrifocalLinearPoint7();
    // Make things easier by working in pixel coordinates
    constructA.N1 = new NormalizationPoint2D(0, 1, 0, 1);
    constructA.N2 = new NormalizationPoint2D(0, 1, 0, 1);
    constructA.N3 = new NormalizationPoint2D(0, 1, 0, 1);
    constructA.createLinearSystem(observations);
    DMatrixRMaj A = constructA.A;
    // extract epipoles
    Point3D_F64 e2 = new Point3D_F64();
    Point3D_F64 e3 = new Point3D_F64();
    MultiViewOps.extractEpipoles(tensor, e2, e3);
    EnforceTrifocalGeometry alg = new EnforceTrifocalGeometry();
    alg.process(e2, e3, A);
    // Check if the found solution is valid by applying the trifocal constraint for 3 points
    TrifocalTensor found = new TrifocalTensor();
    alg.extractSolution(found);
    checkTrifocalWithConstraint(found, 1e-6);
    // make sure the errors are zero too
    DMatrixRMaj errors = new DMatrixRMaj(observations.size(), 1);
    alg.computeErrorVector(A, errors);
    for (int i = 0; i < errors.numRows; i++) assertEquals(0, errors.get(i), 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) TrifocalTensor(boofcv.struct.geo.TrifocalTensor) NormalizationPoint2D(boofcv.alg.geo.NormalizationPoint2D) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 2 with NormalizationPoint2D

use of boofcv.alg.geo.NormalizationPoint2D in project BoofCV by lessthanoptimal.

the class TestTrifocalLinearPoint7 method checkLinearSystem.

/**
 * Check the linear constraint matrix by seeing if the correct solution is in the null space
 */
@Test
public void checkLinearSystem() {
    TrifocalLinearPoint7 alg = new TrifocalLinearPoint7();
    // construct in pixel coordinates for ease
    alg.N1 = new NormalizationPoint2D(0, 1, 0, 1);
    alg.N2 = new NormalizationPoint2D(0, 1, 0, 1);
    alg.N3 = new NormalizationPoint2D(0, 1, 0, 1);
    // TOOO change back
    alg.createLinearSystem(observationsSpecial);
    DMatrixRMaj A = alg.A;
    DMatrixRMaj X = new DMatrixRMaj(27, 1);
    for (int i = 0; i < 9; i++) {
        X.data[i] = tensor.T1.get(i);
        X.data[i + 9] = tensor.T2.get(i);
        X.data[i + 18] = tensor.T3.get(i);
    }
    DMatrixRMaj Y = new DMatrixRMaj(A.numRows, 1);
    CommonOps_DDRM.mult(A, X, Y);
    for (int i = 0; i < Y.numRows; i++) {
        assertEquals(0, Y.get(i), 1e-7);
    }
}
Also used : NormalizationPoint2D(boofcv.alg.geo.NormalizationPoint2D) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Aggregations

NormalizationPoint2D (boofcv.alg.geo.NormalizationPoint2D)2 DMatrixRMaj (org.ejml.data.DMatrixRMaj)2 Test (org.junit.Test)2 TrifocalTensor (boofcv.struct.geo.TrifocalTensor)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1