Search in sources :

Example 51 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestDecomposeHomography method multipleCalls.

/**
 * Checks to see if the same solution is returned when invoked multiple times
 */
@Test
public void multipleCalls() {
    DMatrixRMaj H = MultiViewOps.createHomography(R, T, d, N);
    DecomposeHomography alg = new DecomposeHomography();
    // call it twice and see if things break
    alg.decompose(H);
    alg.decompose(H);
    List<Se3_F64> foundSE = alg.getSolutionsSE();
    List<Vector3D_F64> foundN = alg.getSolutionsN();
    TestDecomposeEssential.checkUnique(foundSE);
    checkHasOriginal(foundSE, foundN, R, T, d, N);
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 52 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method constraint_Trifocal_lll.

@Test
public void constraint_Trifocal_lll() {
    Point3D_F64 X = new Point3D_F64(0.1, -0.05, 2);
    computeLines(X, line1, line2, line3);
    Vector3D_F64 found = MultiViewOps.constraint(tensor, line1, line2, line3, null);
    assertEquals(0, found.x, 1e-12);
    assertEquals(0, found.y, 1e-12);
    assertEquals(0, found.z, 1e-12);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Vector3D_F64(georegression.struct.point.Vector3D_F64) Test(org.junit.Test)

Example 53 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method createHomography_calibrated.

@Test
public void createHomography_calibrated() {
    DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.01, 0.2, null);
    Vector3D_F64 T = new Vector3D_F64(1, 1, 0.1);
    T.normalize();
    double d = 2;
    Vector3D_F64 N = new Vector3D_F64(0, 0, 1);
    DMatrixRMaj H = MultiViewOps.createHomography(R, T, d, N);
    // Test using the following theorem:  x2 = H*x1
    // a point on the plane
    Point3D_F64 P = new Point3D_F64(0.1, 0.2, d);
    Point2D_F64 x0 = new Point2D_F64(P.x / P.z, P.y / P.z);
    SePointOps_F64.transform(new Se3_F64(R, T), P, P);
    Point2D_F64 x1 = new Point2D_F64(P.x / P.z, P.y / P.z);
    Point2D_F64 found = new Point2D_F64();
    GeometryMath_F64.mult(H, x0, found);
    assertEquals(x1.x, found.x, 1e-8);
    assertEquals(x1.y, found.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Vector3D_F64(georegression.struct.point.Vector3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 54 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method decomposeHomography.

@Test
public void decomposeHomography() {
    DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.2, -0.06, -0.05, null);
    Vector3D_F64 T = new Vector3D_F64(2, 1, -3);
    double d = 2.5;
    Vector3D_F64 N = new Vector3D_F64(0.68, 0.2, -0.06);
    N.normalize();
    DMatrixRMaj H = MultiViewOps.createHomography(R, T, d, N);
    List<Tuple2<Se3_F64, Vector3D_F64>> found = MultiViewOps.decomposeHomography(H);
    assertEquals(4, found.size());
    List<Se3_F64> solutionsSE = new ArrayList<>();
    List<Vector3D_F64> solutionsN = new ArrayList<>();
    for (Tuple2<Se3_F64, Vector3D_F64> t : found) {
        solutionsSE.add(t.data0);
        solutionsN.add(t.data1);
    }
    TestDecomposeHomography.checkHasOriginal(solutionsSE, solutionsN, R, T, d, N);
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) Tuple2(org.ddogleg.struct.Tuple2) DMatrixRMaj(org.ejml.data.DMatrixRMaj) ArrayList(java.util.ArrayList) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 55 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method computeLine.

private Vector3D_F64 computeLine(Point3D_F64 X1, Point3D_F64 X2, Se3_F64 worldToCam, DMatrixRMaj K) {
    Point2D_F64 a = PerspectiveOps.renderPixel(worldToCam, K, X1);
    Point2D_F64 b = PerspectiveOps.renderPixel(worldToCam, K, X2);
    Vector3D_F64 v1 = new Vector3D_F64(b.x - a.x, b.y - a.y, 0);
    Vector3D_F64 v2 = new Vector3D_F64(a.x, a.y, 1);
    Vector3D_F64 norm = new Vector3D_F64();
    GeometryMath_F64.cross(v1, v2, norm);
    norm.normalize();
    double sanity1 = a.x * norm.x + a.y * norm.y + norm.z;
    double sanity2 = b.x * norm.x + b.y * norm.y + norm.z;
    return norm;
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64)

Aggregations

Vector3D_F64 (georegression.struct.point.Vector3D_F64)60 DMatrixRMaj (org.ejml.data.DMatrixRMaj)34 Se3_F64 (georegression.struct.se.Se3_F64)30 Test (org.junit.Test)23 Point3D_F64 (georegression.struct.point.Point3D_F64)15 Point2D_F64 (georegression.struct.point.Point2D_F64)13 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)4 PkltConfig (boofcv.alg.tracker.klt.PkltConfig)4 GrayU8 (boofcv.struct.image.GrayU8)4 MediaManager (boofcv.io.MediaManager)3 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)3 ArrayList (java.util.ArrayList)3 GrayU16 (boofcv.struct.image.GrayU16)2 UtilVector3D_F64 (georegression.geometry.UtilVector3D_F64)2 GeometryUnitTest (georegression.misc.test.GeometryUnitTest)2 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)2 Random (java.util.Random)2 SimpleMatrix (org.ejml.simple.SimpleMatrix)2 ConfigChessboard (boofcv.abst.fiducial.calib.ConfigChessboard)1 AccessPointTracks3D (boofcv.abst.sfm.AccessPointTracks3D)1