Search in sources :

Example 1 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class DisparityPointCloudViewer method createWorldToCamera.

public Se3_F64 createWorldToCamera() {
    // pick an appropriate amount of motion for the scene
    double z = baseline * focalLengthX / (minDisparity + rangeDisparity);
    double adjust = baseline / 20.0;
    Vector3D_F64 rotPt = new Vector3D_F64(offsetX * adjust, offsetY * adjust, z * range);
    double radians = tiltAngle * Math.PI / 180.0;
    DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, radians, 0, 0, null);
    Se3_F64 a = new Se3_F64(R, rotPt);
    return a;
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64)

Example 2 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestDecomposeEssential method multipleCalls.

/**
 * Checks to see if the same solution is returned when invoked multiple times
 */
@Test
public void multipleCalls() {
    DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.4, 0.5, null);
    Vector3D_F64 T = new Vector3D_F64(2, 1, -3);
    DMatrixRMaj E = MultiViewOps.createEssential(R, T);
    DecomposeEssential alg = new DecomposeEssential();
    // call it twice and see if it breaks
    alg.decompose(E);
    alg.decompose(E);
    List<Se3_F64> solutions = alg.getSolutions();
    assertEquals(4, solutions.size());
    checkUnique(solutions);
    checkHasOriginal(solutions, R, T);
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) GeometryUnitTest(georegression.misc.test.GeometryUnitTest) Test(org.junit.Test)

Example 3 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method homographyStereo2Lines.

@Test
public void homographyStereo2Lines() {
    CommonHomographyInducedPlane common = new CommonHomographyInducedPlane();
    PairLineNorm l1 = CommonHomographyInducedPlane.convert(common.p1, common.p2);
    PairLineNorm l2 = CommonHomographyInducedPlane.convert(common.p1, common.p3);
    DMatrixRMaj H = MultiViewOps.homographyStereo2Lines(common.F, l1, l2);
    common.checkHomography(H);
}
Also used : CommonHomographyInducedPlane(boofcv.alg.geo.h.CommonHomographyInducedPlane) DMatrixRMaj(org.ejml.data.DMatrixRMaj) PairLineNorm(boofcv.struct.geo.PairLineNorm) Test(org.junit.Test)

Example 4 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method decomposeCameraMatrix.

@Test
public void decomposeCameraMatrix() {
    // compute an arbitrary projection matrix from known values
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(200, 250, 0.0, 100, 110);
    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 P = new DMatrixRMaj(3, 4);
    DMatrixRMaj KP = new DMatrixRMaj(3, 4);
    CommonOps_DDRM.insert(R, P, 0, 0);
    P.set(0, 3, T.x);
    P.set(1, 3, T.y);
    P.set(2, 3, T.z);
    CommonOps_DDRM.mult(K, P, KP);
    // decompose the projection matrix
    DMatrixRMaj foundK = new DMatrixRMaj(3, 3);
    Se3_F64 foundPose = new Se3_F64();
    MultiViewOps.decomposeCameraMatrix(KP, foundK, foundPose);
    // recompute the projection matrix found the found results
    DMatrixRMaj foundKP = new DMatrixRMaj(3, 4);
    CommonOps_DDRM.insert(foundPose.getR(), P, 0, 0);
    P.set(0, 3, foundPose.T.x);
    P.set(1, 3, foundPose.T.y);
    P.set(2, 3, foundPose.T.z);
    CommonOps_DDRM.mult(foundK, P, foundKP);
    // see if the two projection matrices are the same
    assertTrue(MatrixFeatures_DDRM.isEquals(foundKP, KP, 1e-8));
}
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 5 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method canonicalCamera.

@Test
public void canonicalCamera() {
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(200, 250, 0.0, 100, 110);
    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);
    DMatrixRMaj F = MultiViewOps.createFundamental(E, K);
    Point3D_F64 e1 = new Point3D_F64();
    Point3D_F64 e2 = new Point3D_F64();
    CommonOps_DDRM.scale(-2.0 / F.get(0, 1), F);
    MultiViewOps.extractEpipoles(F, e1, e2);
    DMatrixRMaj P = MultiViewOps.canonicalCamera(F, e2, new Vector3D_F64(1, 1, 1), 2);
    // recompose the fundamental matrix using the special equation for canonical cameras
    DMatrixRMaj foundF = new DMatrixRMaj(3, 3);
    DMatrixRMaj crossEpi = new DMatrixRMaj(3, 3);
    GeometryMath_F64.crossMatrix(e2, crossEpi);
    DMatrixRMaj M = new DMatrixRMaj(3, 3);
    CommonOps_DDRM.extract(P, 0, 3, 0, 3, M, 0, 0);
    CommonOps_DDRM.mult(crossEpi, M, foundF);
    // see if they are equal up to a scale factor
    CommonOps_DDRM.scale(1.0 / foundF.get(0, 1), foundF);
    CommonOps_DDRM.scale(1.0 / F.get(0, 1), F);
    assertTrue(MatrixFeatures_DDRM.isIdentical(F, foundF, 1e-8));
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

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