Search in sources :

Example 56 with Vector3D_F64

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

the class TestMultiViewOps method createHomography_uncalibrated.

@Test
public void createHomography_uncalibrated() {
    DMatrixRMaj K = new DMatrixRMaj(3, 3, true, 0.1, 0.001, 200, 0, 0.2, 250, 0, 0, 1);
    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, K);
    // 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);
    GeometryMath_F64.mult(K, x0, x0);
    SePointOps_F64.transform(new Se3_F64(R, T), P, P);
    Point2D_F64 x1 = new Point2D_F64(P.x / P.z, P.y / P.z);
    GeometryMath_F64.mult(K, x1, x1);
    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 57 with Vector3D_F64

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

the class TestMultiViewOps method constraint_homography.

@Test
public void constraint_homography() {
    double d = 2;
    Vector3D_F64 N = new Vector3D_F64(0, 0, 1);
    Point3D_F64 X = new Point3D_F64(0.1, -0.4, d);
    DMatrixRMaj H = MultiViewOps.createHomography(worldToCam2.getR(), worldToCam2.getT(), d, N);
    Point2D_F64 p1 = PerspectiveOps.renderPixel(new Se3_F64(), null, X);
    Point2D_F64 p2 = PerspectiveOps.renderPixel(worldToCam2, null, X);
    Point2D_F64 found = MultiViewOps.constraintHomography(H, p1, null);
    assertEquals(p2.x, found.x, 1e-8);
    assertEquals(p2.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 58 with Vector3D_F64

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

the class TestPositiveDepthConstraintCheck method testNegative.

/**
 * Point a point in behind the cameras
 */
@Test
public void testNegative() {
    // create transform from A to B
    DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -0.05, 0, null);
    Vector3D_F64 T = new Vector3D_F64(1, 0, 0);
    Se3_F64 fromAtoB = new Se3_F64(R, T);
    // point in front of both cameras
    Point3D_F64 pt = new Point3D_F64(0, 0, -1);
    // create observations of the point in calibrated coordinates
    Point2D_F64 obsA = new Point2D_F64(0, 0);
    Point3D_F64 pt_inB = SePointOps_F64.transform(fromAtoB, pt, null);
    Point2D_F64 obsB = new Point2D_F64(pt_inB.x / pt_inB.z, pt_inB.y / pt_inB.z);
    PositiveDepthConstraintCheck alg = new PositiveDepthConstraintCheck();
    assertFalse(alg.checkConstraint(obsA, obsB, fromAtoB));
}
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 59 with Vector3D_F64

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

the class TestParamFundamentalEpipolar method backAndForth.

@Test
public void backAndForth() {
    DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 1, 2, -0.5, null);
    Vector3D_F64 T = new Vector3D_F64(0.5, 0.7, -0.3);
    DMatrixRMaj E = MultiViewOps.createEssential(R, T);
    double[] param = new double[7];
    ParamFundamentalEpipolar alg = new ParamFundamentalEpipolar();
    DMatrixRMaj found = new DMatrixRMaj(3, 3);
    alg.encode(E, param);
    alg.decode(param, found);
    // normalize to take in account scale different when testing
    CommonOps_DDRM.divide(E.get(2, 2), E);
    CommonOps_DDRM.divide(found.get(2, 2), found);
    assertTrue(MatrixFeatures_DDRM.isEquals(E, found, 1e-8));
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 60 with Vector3D_F64

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

the class TestNarrowToWidePtoP_F64 method checkFOVBounds.

/**
 * Request points at the border and see if it has the expected vertical and horizontal FOV
 */
@Test
public void checkFOVBounds() {
    NarrowToWidePtoP_F64 alg = createAlg();
    Point2D_F64 foundA = new Point2D_F64();
    Point2D_F64 foundB = new Point2D_F64();
    Point3D_F64 vA = new Point3D_F64();
    Point3D_F64 vB = new Point3D_F64();
    // Compute the horizontal FOV
    alg.compute(0, 250, foundA);
    alg.compute(500, 250, foundB);
    Point2Transform3_F64 wideToSphere = createModelWide().undistortPtoS_F64();
    wideToSphere.compute(foundA.x, foundA.y, vA);
    wideToSphere.compute(foundB.x, foundB.y, vB);
    double found = UtilVector3D_F64.acute(new Vector3D_F64(vA), new Vector3D_F64(vB));
    double expected = 2.0 * Math.atan(250.0 / 400.0);
    assertEquals(expected, found, 0.01);
    // Compute the vertical FOV
    alg.compute(250, 0, foundA);
    alg.compute(250, 500, foundB);
    wideToSphere.compute(foundA.x, foundA.y, vA);
    wideToSphere.compute(foundB.x, foundB.y, vB);
    found = UtilVector3D_F64.acute(new Vector3D_F64(vA), new Vector3D_F64(vB));
    expected = 2.0 * Math.atan(250.0 / 400.0);
    assertEquals(expected, found, 0.001);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Vector3D_F64(georegression.struct.point.Vector3D_F64) UtilVector3D_F64(georegression.geometry.UtilVector3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform3_F64(boofcv.struct.distort.Point2Transform3_F64) Test(org.junit.Test)

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