Search in sources :

Example 16 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method inducedHomography13.

@Test
public void inducedHomography13() {
    Point3D_F64 X = new Point3D_F64(0.1, -0.05, 2);
    computeLines(X, line1, line2, line3);
    // When the tensor was constructed the first view was assumed to be [I|0], which
    // is why normalized image coordinates are used for the first view
    Point2D_F64 p1 = PerspectiveOps.renderPixel(new Se3_F64(), null, X);
    Point2D_F64 p3 = PerspectiveOps.renderPixel(worldToCam3, K, X);
    DMatrixRMaj H13 = MultiViewOps.inducedHomography13(tensor, line2, null);
    Point2D_F64 found = new Point2D_F64();
    GeometryMath_F64.mult(H13, p1, found);
    assertEquals(p3.x, found.x, 1e-8);
    assertEquals(p3.y, found.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_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 17 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method renderPixel_cameramatrix.

@Test
public void renderPixel_cameramatrix() {
    Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
    Se3_F64 worldToCamera = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.05, 0.03, worldToCamera.getR());
    worldToCamera.getT().set(0.2, 0.01, -0.03);
    DMatrixRMaj K = RandomMatrices_DDRM.triangularUpper(3, 0, -1, 1, rand);
    Point3D_F64 X_cam = SePointOps_F64.transform(worldToCamera, X, null);
    Point2D_F64 found;
    DMatrixRMaj P = PerspectiveOps.createCameraMatrix(worldToCamera.R, worldToCamera.T, K, null);
    Point2D_F64 expected = new Point2D_F64();
    expected.x = X_cam.x / X_cam.z;
    expected.y = X_cam.y / X_cam.z;
    GeometryMath_F64.mult(K, expected, expected);
    found = PerspectiveOps.renderPixel(P, X);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_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 18 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method scaleIntrinsic.

@Test
public void scaleIntrinsic() {
    Point3D_F64 X = new Point3D_F64(0.1, 0.3, 2);
    CameraPinholeRadial param = new CameraPinholeRadial(200, 300, 2, 250, 260, 200, 300);
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
    // find the pixel location in the unscaled image
    Point2D_F64 a = PerspectiveOps.renderPixel(new Se3_F64(), K, X);
    PerspectiveOps.scaleIntrinsic(param, 0.5);
    K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
    // find the pixel location in the scaled image
    Point2D_F64 b = PerspectiveOps.renderPixel(new Se3_F64(), K, X);
    assertEquals(a.x * 0.5, b.x, 1e-8);
    assertEquals(a.y * 0.5, b.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 19 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method renderPixel_SE.

@Test
public void renderPixel_SE() {
    Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
    Se3_F64 worldToCamera = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.05, 0.03, worldToCamera.getR());
    worldToCamera.getT().set(0.2, 0.01, -0.03);
    DMatrixRMaj K = RandomMatrices_DDRM.triangularUpper(3, 0, -1, 1, rand);
    Point3D_F64 X_cam = SePointOps_F64.transform(worldToCamera, X, null);
    Point2D_F64 found;
    // calibrated case
    found = PerspectiveOps.renderPixel(worldToCamera, null, X);
    assertEquals(X_cam.x / X_cam.z, found.x, 1e-8);
    assertEquals(X_cam.y / X_cam.z, found.y, 1e-8);
    // uncalibrated case
    Point2D_F64 expected = new Point2D_F64();
    expected.x = X_cam.x / X_cam.z;
    expected.y = X_cam.y / X_cam.z;
    GeometryMath_F64.mult(K, expected, expected);
    found = PerspectiveOps.renderPixel(worldToCamera, K, X);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_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 20 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class TestPositiveDepthConstraintCheck method testPositive.

/**
 * Point a point in front of both cameras and see if it returns true
 */
@Test
public void testPositive() {
    // 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, 2);
    // 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();
    assertTrue(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)

Aggregations

Se3_F64 (georegression.struct.se.Se3_F64)214 Test (org.junit.Test)83 Point3D_F64 (georegression.struct.point.Point3D_F64)74 Point2D_F64 (georegression.struct.point.Point2D_F64)68 DMatrixRMaj (org.ejml.data.DMatrixRMaj)52 Point2D3D (boofcv.struct.geo.Point2D3D)31 Vector3D_F64 (georegression.struct.point.Vector3D_F64)30 ArrayList (java.util.ArrayList)27 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)26 GrayF32 (boofcv.struct.image.GrayF32)18 AssociatedPair (boofcv.struct.geo.AssociatedPair)17 StereoParameters (boofcv.struct.calib.StereoParameters)12 GrayU8 (boofcv.struct.image.GrayU8)10 BufferedImage (java.awt.image.BufferedImage)10 PointTrack (boofcv.abst.feature.tracker.PointTrack)9 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)9 Stereo2D3D (boofcv.struct.sfm.Stereo2D3D)9 ModelManagerSe3_F64 (georegression.fitting.se.ModelManagerSe3_F64)9 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)8 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)7