Search in sources :

Example 66 with CameraPinholeRadial

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

the class TestPerspectiveOps method convertPixelToNorm_intrinsic_F64.

@Test
public void convertPixelToNorm_intrinsic_F64() {
    CameraPinholeRadial intrinsic = new CameraPinholeRadial(100, 150, 0.1, 120, 209, 500, 600);
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(intrinsic, (DMatrixRMaj) null);
    DMatrixRMaj K_inv = new DMatrixRMaj(3, 3);
    CommonOps_DDRM.invert(K, K_inv);
    Point2D_F64 pixel = new Point2D_F64(100, 120);
    Point2D_F64 expected = new Point2D_F64();
    GeometryMath_F64.mult(K_inv, pixel, expected);
    Point2D_F64 found = PerspectiveOps.convertPixelToNorm(intrinsic, pixel, null);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 67 with CameraPinholeRadial

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

the class TestPerspectiveOps method convertNormToPixel_intrinsic_F64.

@Test
public void convertNormToPixel_intrinsic_F64() {
    CameraPinholeRadial intrinsic = new CameraPinholeRadial(100, 150, 0.1, 120, 209, 500, 600);
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(intrinsic, (DMatrixRMaj) null);
    Point2D_F64 norm = new Point2D_F64(-0.1, 0.25);
    Point2D_F64 expected = new Point2D_F64();
    GeometryMath_F64.mult(K, norm, expected);
    Point2D_F64 found = PerspectiveOps.convertNormToPixel(intrinsic, norm.x, norm.y, null);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 68 with CameraPinholeRadial

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

the class TestPerspectiveOps method adjustIntrinsic.

@Test
public void adjustIntrinsic() {
    DMatrixRMaj B = new DMatrixRMaj(3, 3, true, 2, 0, 1, 0, 3, 2, 0, 0, 1);
    CameraPinholeRadial param = new CameraPinholeRadial(200, 300, 2, 250, 260, 200, 300).fsetRadial(0.1, 0.3);
    CameraPinholeRadial found = PerspectiveOps.adjustIntrinsic(param, B, null);
    DMatrixRMaj A = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
    DMatrixRMaj expected = new DMatrixRMaj(3, 3);
    CommonOps_DDRM.mult(B, A, expected);
    assertArrayEquals(param.radial, found.radial, 1e-8);
    DMatrixRMaj foundM = PerspectiveOps.calibrationMatrix(found, (DMatrixRMaj) null);
    assertTrue(MatrixFeatures_DDRM.isIdentical(expected, foundM, 1e-8));
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 69 with CameraPinholeRadial

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

the class TestRectifyImageOps method transform_PixelToRect_and_RectToPixel_F64.

@Test
public void transform_PixelToRect_and_RectToPixel_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);
    Point2Transform2_F64 forward = RectifyImageOps.transformPixelToRect(param, rect);
    Point2Transform2_F64 inverse = RectifyImageOps.transformRectToPixel(param, rect);
    double x = 20, y = 30;
    Point2D_F64 out = new Point2D_F64();
    forward.compute(x, y, out);
    // sanity check
    assertTrue(Math.abs(x - out.x) > 1e-8);
    assertTrue(Math.abs(y - out.y) > 1e-8);
    inverse.compute(out.x, out.y, out);
    assertEquals(x, out.x, 1e-5);
    assertEquals(y, out.y, 1e-5);
}
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 70 with CameraPinholeRadial

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

the class TestRectifyImageOps method transform_PixelToRect_and_RectToPixel_F32.

/**
 * Transforms and then performs the inverse transform to distorted rectified pixel
 */
@Test
public void transform_PixelToRect_and_RectToPixel_F32() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    FMatrixRMaj rect = new FMatrixRMaj(3, 3, true, 1.1f, 0, 0, 0, 2, 0, 0.1f, 0, 3);
    Point2Transform2_F32 forward = RectifyImageOps.transformPixelToRect(param, rect);
    Point2Transform2_F32 inverse = RectifyImageOps.transformRectToPixel(param, rect);
    float x = 20, y = 30;
    Point2D_F32 out = new Point2D_F32();
    forward.compute(x, y, out);
    // sanity check
    assertTrue(Math.abs(x - out.x) > 1e-4);
    assertTrue(Math.abs(y - out.y) > 1e-4);
    inverse.compute(out.x, out.y, out);
    assertEquals(x, out.x, 1e-4);
    assertEquals(y, out.y, 1e-4);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) 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