Search in sources :

Example 6 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial 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 7 with CameraPinholeRadial

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

the class TestPerspectiveOps method renderPixel_intrinsic.

@Test
public void renderPixel_intrinsic() {
    Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
    CameraPinholeRadial intrinsic = new CameraPinholeRadial(100, 150, 0.1, 120, 209, 500, 600);
    double normX = X.x / X.z;
    double normY = X.y / X.z;
    Point2D_F64 expected = new Point2D_F64();
    PerspectiveOps.convertNormToPixel(intrinsic, normX, normY, expected);
    Point2D_F64 found = PerspectiveOps.renderPixel(intrinsic, X);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 8 with CameraPinholeRadial

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

the class TestPerspectiveOps method guessIntrinsic_one.

@Test
public void guessIntrinsic_one() {
    double hfov = 30;
    CameraPinholeRadial found = PerspectiveOps.createIntrinsic(640, 480, hfov);
    assertEquals(UtilAngle.degreeToRadian(hfov), 2.0 * Math.atan(found.cx / found.fx), 1e-6);
    assertEquals(found.fx, found.fy, 1e-6);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Test(org.junit.Test)

Example 9 with CameraPinholeRadial

use of boofcv.struct.calib.CameraPinholeRadial 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 10 with CameraPinholeRadial

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

the class TestRectifyImageOps method fullViewLeft_calibrated.

/**
 * After the camera matrix has been adjusted and a forward rectification transform has been applied
 * the output image will be shrink and contained inside the output image.
 */
@Test
public void fullViewLeft_calibrated() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    // do nothing rectification
    FMatrixRMaj rect1 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rect2 = CommonOps_FDRM.identity(3);
    FMatrixRMaj rectK = PerspectiveOps.calibrationMatrix(param, (FMatrixRMaj) null);
    RectifyImageOps.fullViewLeft(param, rect1, rect2, rectK);
    // check left image
    Point2Transform2_F32 tran = RectifyImageOps.transformPixelToRect(param, rect1);
    checkInside(tran);
// the right view is not checked since it is not part of the contract
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) 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