Search in sources :

Example 11 with Point2D_F32

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

the class TestNarrowToWidePtoP_F32 method checkFOVBounds.

/**
 * Request points at the border and see if it has the expected vertical and horizontal FOV
 */
@Test
public void checkFOVBounds() {
    NarrowToWidePtoP_F32 alg = createAlg();
    Point2D_F32 foundA = new Point2D_F32();
    Point2D_F32 foundB = new Point2D_F32();
    Point3D_F32 vA = new Point3D_F32();
    Point3D_F32 vB = new Point3D_F32();
    // Compute the horizontal FOV
    alg.compute(0, 250, foundA);
    alg.compute(500, 250, foundB);
    Point2Transform3_F32 wideToSphere = createModelWide().undistortPtoS_F32();
    wideToSphere.compute(foundA.x, foundA.y, vA);
    wideToSphere.compute(foundB.x, foundB.y, vB);
    float found = UtilVector3D_F32.acute(new Vector3D_F32(vA), new Vector3D_F32(vB));
    float expected = 2.0f * (float) Math.atan(250.0f / 400.0f);
    assertEquals(expected, found, 0.01f);
    // 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_F32.acute(new Vector3D_F32(vA), new Vector3D_F32(vB));
    expected = 2.0f * (float) Math.atan(250.0f / 400.0f);
    assertEquals(expected, found, 0.001f);
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) Vector3D_F32(georegression.struct.point.Vector3D_F32) UtilVector3D_F32(georegression.geometry.UtilVector3D_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform3_F32(boofcv.struct.distort.Point2Transform3_F32) Test(org.junit.Test)

Example 12 with Point2D_F32

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

the class TestRemovePerspectiveDistortion method identity.

/**
 * The transform should not scale and produce a simple transform from input to output
 */
@Test
public void identity() {
    RemovePerspectiveDistortion<GrayF32> alg = new RemovePerspectiveDistortion<>(30, 40, ImageType.single(GrayF32.class));
    alg.createTransform(new Point2D_F64(20, 30), new Point2D_F64(50, 30), new Point2D_F64(50, 70), new Point2D_F64(20, 70));
    Point2D_F32 p = new Point2D_F32();
    PointTransformHomography_F32 transform = alg.getTransform();
    transform.compute(0, 0, p);
    assertTrue(p.distance(20, 30) < UtilEjml.TEST_F64);
    transform.compute(30, 40, p);
    assertTrue(p.distance(50, 70) < UtilEjml.TEST_F64);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Point2D_F64(georegression.struct.point.Point2D_F64) Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 13 with Point2D_F32

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

the class TestTransformThenPixel_F32 method compute.

@Test
public void compute() {
    Transform2ThenPixel_F32 alg = new Transform2ThenPixel_F32(new Dummy());
    alg.set(1, 2, 3, 4, 5);
    float nx = 0.1f, ny = 0.2f;
    float expectedX = 1 * nx + 3 * ny + 4;
    float expectedY = 2 * ny + 5;
    Point2D_F32 found = new Point2D_F32();
    alg.compute(1, 2, found);
    assertEquals(expectedX, found.x, 1e-8);
    assertEquals(expectedY, found.y, 1e-8);
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 14 with Point2D_F32

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

the class TestPinholeNtoP_F32 method basicTest.

@Test
public void basicTest() {
    CameraPinholeRadial p = new CameraPinholeRadial().fsetK(1, 2, 3, 4, 5, 200, 300);
    FMatrixRMaj K = PerspectiveOps.calibrationMatrix(p, (FMatrixRMaj) null);
    Point2D_F32 pixel = new Point2D_F32(150, 200);
    Point2D_F32 expected = new Point2D_F32();
    Point2D_F32 found = new Point2D_F32();
    GeometryMath_F32.mult(K, pixel, expected);
    PinholeNtoP_F32 alg = new PinholeNtoP_F32();
    alg.set(p.fx, p.fy, p.skew, p.cx, p.cy);
    alg.compute(pixel.x, pixel.y, found);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 15 with Point2D_F32

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

the class TestEquirectangularTools_F32 method equiToNorm_reverse.

private void equiToNorm_reverse(EquirectangularTools_F32 tools, float x, float y) {
    Point3D_F32 n = new Point3D_F32();
    Point2D_F32 r = new Point2D_F32();
    tools.equiToNorm(x, y, n);
    tools.normToEqui(n.x, n.y, n.z, r);
    assertEquals(x, r.x, GrlConstants.TEST_F32);
    assertEquals(y, r.y, GrlConstants.TEST_F32);
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) Point2D_F32(georegression.struct.point.Point2D_F32)

Aggregations

Point2D_F32 (georegression.struct.point.Point2D_F32)98 Test (org.junit.Test)36 Point3D_F32 (georegression.struct.point.Point3D_F32)10 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)9 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)8 ArrayList (java.util.ArrayList)8 Point2D_F64 (georegression.struct.point.Point2D_F64)7 FMatrixRMaj (org.ejml.data.FMatrixRMaj)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)5 Point2Transform3_F32 (boofcv.struct.distort.Point2Transform3_F32)4 Point3Transform2_F32 (boofcv.struct.distort.Point3Transform2_F32)4 GrayF32 (boofcv.struct.image.GrayF32)4 ClosestPoint2D_F32 (georegression.metric.ClosestPoint2D_F32)4 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU8 (boofcv.struct.image.GrayU8)3 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)2 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)2 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2