Search in sources :

Example 71 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class TestRectifyImageOps method transformPixelToRectNorm_F64.

/**
 * Test by using other tested functions, then manually applying the last step
 */
@Test
public void transformPixelToRectNorm_F64() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    DMatrixRMaj rect = new DMatrixRMaj(3, 3, true, 1.1, 0, 0, 0, 2, 0, 0.1, 0, 3);
    DMatrixRMaj rectK = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
    DMatrixRMaj rectK_inv = new DMatrixRMaj(3, 3);
    CommonOps_DDRM.invert(rectK, rectK_inv);
    Point2Transform2_F64 tranRect = RectifyImageOps.transformPixelToRect(param, rect);
    Point2Transform2_F64 alg = RectifyImageOps.transformPixelToRectNorm(param, rect, rectK);
    double x = 10, y = 20;
    // compute expected results
    Point2D_F64 rectified = new Point2D_F64();
    tranRect.compute(x, y, rectified);
    Point2D_F64 expected = new Point2D_F64();
    GeometryMath_F64.mult(rectK_inv, new Point2D_F64(rectified.x, rectified.y), expected);
    // compute the 'found' results
    Point2D_F64 found = new Point2D_F64();
    alg.compute(x, y, found);
    assertEquals(expected.x, found.x, 1e-4);
    assertEquals(expected.y, found.y, 1e-4);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) Test(org.junit.Test)

Example 72 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class TestPinholeRadialToEquirectangular_F32 method setDirection.

/**
 * Rotate the camera and see if the camera center is pointing in the right direction now
 */
@Test
public void setDirection() {
    CameraPinholeRadial intrinsic = new CameraPinholeRadial(400, 400, 0, imgWidth / 2, imgHeight / 2, imgWidth, imgHeight);
    intrinsic.setRadial(0.1f, 0.2f);
    PinholeRadialToEquirectangular_F32 alg = new PinholeRadialToEquirectangular_F32();
    alg.setPinhole(intrinsic);
    alg.setEquirectangularShape(equiWidth, equiHeight);
    alg.setDirection(0, (float) Math.PI / 2, 0);
    assertPointing(alg, imgWidth / 2, imgHeight / 2, 1, 0, 0);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Test(org.junit.Test)

Example 73 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class TestPinholeRadialToEquirectangular_F32 method canonicalIsPointedPositiveZ.

/**
 * Makes sure the canonical orientation is pointed along the positive z axis.  This is done by projecting
 * the center of the pinhole at default orientation.
 */
@Test
public void canonicalIsPointedPositiveZ() {
    CameraPinholeRadial intrinsic = new CameraPinholeRadial(400, 400, 0, imgWidth / 2, imgHeight / 2, imgWidth, imgHeight);
    intrinsic.setRadial(0.1f, 0.2f);
    PinholeRadialToEquirectangular_F32 alg = new PinholeRadialToEquirectangular_F32();
    alg.setPinhole(intrinsic);
    alg.setEquirectangularShape(equiWidth, equiHeight);
    assertPointing(alg, imgWidth / 2, imgHeight / 2, 0, 0, 1);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Test(org.junit.Test)

Example 74 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class TestPinholeRadialToEquirectangular_F64 method canonicalIsPointedPositiveZ.

/**
 * Makes sure the canonical orientation is pointed along the positive z axis.  This is done by projecting
 * the center of the pinhole at default orientation.
 */
@Test
public void canonicalIsPointedPositiveZ() {
    CameraPinholeRadial intrinsic = new CameraPinholeRadial(400, 400, 0, imgWidth / 2, imgHeight / 2, imgWidth, imgHeight);
    intrinsic.setRadial(0.1, 0.2);
    PinholeRadialToEquirectangular_F64 alg = new PinholeRadialToEquirectangular_F64();
    alg.setPinhole(intrinsic);
    alg.setEquirectangularShape(equiWidth, equiHeight);
    assertPointing(alg, imgWidth / 2, imgHeight / 2, 0, 0, 1);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Test(org.junit.Test)

Example 75 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.

the class TestPinholeRadialToEquirectangular_F64 method setDirection.

/**
 * Rotate the camera and see if the camera center is pointing in the right direction now
 */
@Test
public void setDirection() {
    CameraPinholeRadial intrinsic = new CameraPinholeRadial(400, 400, 0, imgWidth / 2, imgHeight / 2, imgWidth, imgHeight);
    intrinsic.setRadial(0.1, 0.2);
    PinholeRadialToEquirectangular_F64 alg = new PinholeRadialToEquirectangular_F64();
    alg.setPinhole(intrinsic);
    alg.setEquirectangularShape(equiWidth, equiHeight);
    alg.setDirection(0, Math.PI / 2, 0);
    assertPointing(alg, imgWidth / 2, imgHeight / 2, 1, 0, 0);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Test(org.junit.Test)

Aggregations

CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)81 Test (org.junit.Test)37 Se3_F64 (georegression.struct.se.Se3_F64)26 GrayF32 (boofcv.struct.image.GrayF32)19 Point2D_F64 (georegression.struct.point.Point2D_F64)16 File (java.io.File)15 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)12 BufferedImage (java.awt.image.BufferedImage)12 DMatrixRMaj (org.ejml.data.DMatrixRMaj)12 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)10 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)9 CameraPinhole (boofcv.struct.calib.CameraPinhole)9 Point3D_F64 (georegression.struct.point.Point3D_F64)8 ArrayList (java.util.ArrayList)7 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)6 StereoParameters (boofcv.struct.calib.StereoParameters)6 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)6 Point2D_F32 (georegression.struct.point.Point2D_F32)5 FMatrixRMaj (org.ejml.data.FMatrixRMaj)5 GrayU8 (boofcv.struct.image.GrayU8)4