Search in sources :

Example 1 with Point3D_F32

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

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

Example 3 with Point3D_F32

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

the class TestEquirectangularTools_F32 method equiToNorm.

/**
 * Test one very simple case with a known answer
 */
@Test
public void equiToNorm() {
    EquirectangularTools_F32 tools = new EquirectangularTools_F32();
    tools.configure(300, 250);
    Point3D_F32 found = new Point3D_F32();
    tools.equiToNorm(300.0f / 2.0f, 249.0f / 2.0f, found);
    assertEquals(1.0f, found.x, GrlConstants.TEST_F32);
    assertEquals(0.0f, found.y, GrlConstants.TEST_F32);
    assertEquals(0.0f, found.z, GrlConstants.TEST_F32);
    tools.equiToNorm(0, 249 / 2.0f, found);
    assertTrue(found.distance(new Point3D_F32(-1, 0, 0)) <= GrlConstants.TEST_F32);
    tools.equiToNorm(300, 249 / 2.0f, found);
    assertTrue(found.distance(new Point3D_F32(-1, 0, 0)) <= GrlConstants.TEST_F32);
    tools.equiToNorm(300 / 4, 249 / 2.0f, found);
    assertTrue(found.distance(new Point3D_F32(0, -1, 0)) <= GrlConstants.TEST_F32);
    tools.equiToNorm(3 * 300 / 4, 249 / 2.0f, found);
    assertTrue(found.distance(new Point3D_F32(0, 1, 0)) <= GrlConstants.TEST_F32);
    tools.equiToNorm(300 / 2, 0, found);
    assertTrue(found.distance(new Point3D_F32(0, 0, 1)) <= GrlConstants.TEST_F32);
    tools.equiToNorm(300 / 2, 249, found);
    assertTrue(found.distance(new Point3D_F32(0, 0, -1)) <= GrlConstants.TEST_F32);
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) Test(org.junit.Test)

Example 4 with Point3D_F32

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

the class TestUniOmniPtoS_F32 method back_and_forth.

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

Example 5 with Point3D_F32

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

the class TestUniOmniPtoS_F32 method centerIsCenter.

private void centerIsCenter(float mirror) {
    CameraUniversalOmni model = createModel(mirror);
    UniOmniPtoS_F32 alg = new UniOmniPtoS_F32();
    alg.setModel(model);
    Point3D_F32 found = new Point3D_F32(10, 10, 10);
    // directly forward on unit sphere
    alg.compute(320, 240, found);
    assertEquals(0, found.x, GrlConstants.TEST_F32);
    assertEquals(0, found.y, GrlConstants.TEST_F32);
    assertEquals(1, found.z, GrlConstants.TEST_F32);
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) CameraUniversalOmni(boofcv.struct.calib.CameraUniversalOmni)

Aggregations

Point3D_F32 (georegression.struct.point.Point3D_F32)18 Point2D_F32 (georegression.struct.point.Point2D_F32)10 Point2Transform3_F32 (boofcv.struct.distort.Point2Transform3_F32)4 Test (org.junit.Test)4 Point3Transform2_F32 (boofcv.struct.distort.Point3Transform2_F32)3 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)2 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)2 CameraUniversalOmni (boofcv.struct.calib.CameraUniversalOmni)2 GrayF32 (boofcv.struct.image.GrayF32)2 UtilVector3D_F32 (georegression.geometry.UtilVector3D_F32)2 Vector3D_F32 (georegression.struct.point.Vector3D_F32)2 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)1 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)1 PixelTransform2_F32 (boofcv.struct.distort.PixelTransform2_F32)1 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)1 Rodrigues_F32 (georegression.struct.so.Rodrigues_F32)1 ArrayList (java.util.ArrayList)1 FMatrixRMaj (org.ejml.data.FMatrixRMaj)1