Search in sources :

Example 16 with Point3D_F64

use of georegression.struct.point.Point3D_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 17 with Point3D_F64

use of georegression.struct.point.Point3D_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)

Example 18 with Point3D_F64

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

the class TestEquirectangularTools_F64 method equiToNorm_reverse.

private void equiToNorm_reverse(EquirectangularTools_F64 tools, double x, double y) {
    Point3D_F64 n = new Point3D_F64();
    Point2D_F64 r = new Point2D_F64();
    tools.equiToNorm(x, y, n);
    tools.normToEqui(n.x, n.y, n.z, r);
    assertEquals(x, r.x, GrlConstants.TEST_F64);
    assertEquals(y, r.y, GrlConstants.TEST_F64);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64)

Example 19 with Point3D_F64

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

the class GeneralTestRefineTriangulate method perfectInput.

@Test
public void perfectInput() {
    createScene();
    Point3D_F64 initial = worldPoint.copy();
    Point3D_F64 found = new Point3D_F64();
    triangulate(obsPts, motionWorldToCamera, essential, initial, found);
    assertEquals(worldPoint.x, found.x, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Test(org.junit.Test)

Example 20 with Point3D_F64

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

the class TestUniOmniPtoS_F64 method back_and_forth.

private void back_and_forth(double mirror) {
    CameraUniversalOmni model = createModel(mirror);
    UniOmniPtoS_F64 pixelToUnit = new UniOmniPtoS_F64();
    pixelToUnit.setModel(model);
    UniOmniStoP_F64 unitToPixel = new UniOmniStoP_F64();
    unitToPixel.setModel(model);
    List<Point2D_F64> listPixels = new ArrayList<>();
    listPixels.add(new Point2D_F64(320, 240));
    listPixels.add(new Point2D_F64(320, 200));
    listPixels.add(new Point2D_F64(320, 280));
    listPixels.add(new Point2D_F64(280, 240));
    listPixels.add(new Point2D_F64(360, 240));
    listPixels.add(new Point2D_F64(280, 240));
    listPixels.add(new Point2D_F64(240, 180));
    for (Point2D_F64 pixel : listPixels) {
        Point3D_F64 circle = new Point3D_F64(10, 10, 10);
        // directly forward on unit sphere
        pixelToUnit.compute(pixel.x, pixel.y, circle);
        // it should be on the unit circle
        assertEquals(1.0, circle.norm(), GrlConstants.TEST_F64);
        Point2D_F64 found = new Point2D_F64();
        unitToPixel.compute(circle.x, circle.y, circle.z, found);
        assertEquals(pixel.x, found.x, GrlConstants.TEST_SQ_F64);
        assertEquals(pixel.y, found.y, GrlConstants.TEST_SQ_F64);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) CameraUniversalOmni(boofcv.struct.calib.CameraUniversalOmni) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList)

Aggregations

Point3D_F64 (georegression.struct.point.Point3D_F64)174 Point2D_F64 (georegression.struct.point.Point2D_F64)85 Test (org.junit.Test)77 Se3_F64 (georegression.struct.se.Se3_F64)74 DMatrixRMaj (org.ejml.data.DMatrixRMaj)46 ArrayList (java.util.ArrayList)17 Vector3D_F64 (georegression.struct.point.Vector3D_F64)15 Point2D3D (boofcv.struct.geo.Point2D3D)13 AssociatedPair (boofcv.struct.geo.AssociatedPair)12 GrayU8 (boofcv.struct.image.GrayU8)9 FastQueue (org.ddogleg.struct.FastQueue)9 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)8 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)7 MotionTransformPoint (georegression.fitting.MotionTransformPoint)7 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)7 PointTrack (boofcv.abst.feature.tracker.PointTrack)5 StereoParameters (boofcv.struct.calib.StereoParameters)5 TrifocalTensor (boofcv.struct.geo.TrifocalTensor)5 GrayU16 (boofcv.struct.image.GrayU16)5 Stereo2D3D (boofcv.struct.sfm.Stereo2D3D)5