Search in sources :

Example 31 with CameraPinholeBrown

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

the class TestPerspectiveOps method scaleIntrinsic.

@Test
void scaleIntrinsic() {
    Point3D_F64 X = new Point3D_F64(0.1, 0.3, 2);
    CameraPinholeBrown param = new CameraPinholeBrown(200, 300, 2, 250, 260, 200, 300);
    DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(param, (DMatrixRMaj) null);
    // find the pixel location in the unscaled image
    Point2D_F64 a = PerspectiveOps.renderPixel(new Se3_F64(), K, X, null);
    PerspectiveOps.scaleIntrinsic(param, 0.5);
    K = PerspectiveOps.pinholeToMatrix(param, (DMatrixRMaj) null);
    // find the pixel location in the scaled image
    Point2D_F64 b = PerspectiveOps.renderPixel(new Se3_F64(), K, X, null);
    assertEquals(a.x * 0.5, b.x, 1e-8);
    assertEquals(a.y * 0.5, b.y, 1e-8);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 32 with CameraPinholeBrown

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

the class TestPerspectiveOps method guessIntrinsic_one.

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

Example 33 with CameraPinholeBrown

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

the class TestPerspectiveOps method convertPixelToNorm_intrinsic_F32.

@Test
void convertPixelToNorm_intrinsic_F32() {
    CameraPinholeBrown intrinsic = new CameraPinholeBrown(100, 150, 0.1, 120, 209, 500, 600).fsetRadial(0.1, -0.05);
    Point2Transform2_F32 p2n = LensDistortionFactory.narrow(intrinsic).undistort_F32(true, false);
    Point2D_F32 pixel = new Point2D_F32(100, 120);
    Point2D_F32 expected = new Point2D_F32();
    p2n.compute(pixel.x, pixel.y, expected);
    Point2D_F32 found = PerspectiveOps.convertPixelToNorm(intrinsic, pixel, null);
    assertEquals(expected.x, found.x, UtilEjml.TEST_F32);
    assertEquals(expected.y, found.y, UtilEjml.TEST_F32);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) Test(org.junit.jupiter.api.Test)

Example 34 with CameraPinholeBrown

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

the class TestPinholeNtoP_F64 method basicTest.

@Test
void basicTest() {
    CameraPinholeBrown p = new CameraPinholeBrown().fsetK(1, 2, 3, 4, 5, 200, 300);
    DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(p, (DMatrixRMaj) null);
    Point2D_F64 pixel = new Point2D_F64(150, 200);
    Point2D_F64 expected = new Point2D_F64();
    Point2D_F64 found = new Point2D_F64();
    GeometryMath_F64.mult(K, pixel, expected);
    PinholeNtoP_F64 alg = new PinholeNtoP_F64();
    alg.setK(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 : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.jupiter.api.Test)

Example 35 with CameraPinholeBrown

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

the class TestLensDistortionOps method changeCameraModel.

/**
 * This is a bit hard to test accurately. That would require computing distorted image and seeing everything lines
 * up properly. For now we just check tos ee if things blow up.
 */
@Test
void changeCameraModel() {
    CameraPinholeBrown original = new CameraPinholeBrown(200, 200, 0, 200, 200, 400, 400);
    CameraPinhole desired = new CameraPinholeBrown(300, 300, 0, 200, 200, 400, 400);
    CameraPinhole modified = new CameraPinhole();
    BorderType[] borders = new BorderType[] { BorderType.EXTENDED, BorderType.SKIP, BorderType.ZERO, BorderType.REFLECT, BorderType.WRAP };
    for (AdjustmentType adj : AdjustmentType.values()) {
        for (BorderType border : borders) {
            ImageDistort<GrayU8, GrayU8> alg = LensDistortionOps.changeCameraModel(adj, border, original, desired, modified, ImageType.single(GrayU8.class));
            // do a few more tests to see of dubious value. if the underlying implementation changes
            // this test will need to be updated
            assertTrue(alg instanceof ImageDistortCache_SB);
            ImageDistortCache_SB _alg = (ImageDistortCache_SB) alg;
            assertTrue(_alg.interp instanceof ImplBilinearPixel_U8);
        }
    }
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) GrayU8(boofcv.struct.image.GrayU8) CameraPinhole(boofcv.struct.calib.CameraPinhole) BorderType(boofcv.struct.border.BorderType) ImplBilinearPixel_U8(boofcv.alg.interpolate.impl.ImplBilinearPixel_U8) Test(org.junit.jupiter.api.Test)

Aggregations

CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)99 Test (org.junit.jupiter.api.Test)62 Se3_F64 (georegression.struct.se.Se3_F64)39 GrayF32 (boofcv.struct.image.GrayF32)29 Point2D_F64 (georegression.struct.point.Point2D_F64)19 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)16 LensDistortionBrown (boofcv.alg.distort.brown.LensDistortionBrown)14 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)14 BufferedImage (java.awt.image.BufferedImage)14 ArrayList (java.util.ArrayList)12 CameraPinhole (boofcv.struct.calib.CameraPinhole)11 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)10 DMatrixRMaj (org.ejml.data.DMatrixRMaj)10 File (java.io.File)9 StereoParameters (boofcv.struct.calib.StereoParameters)6 GrayU8 (boofcv.struct.image.GrayU8)6 Point3D_F64 (georegression.struct.point.Point3D_F64)6 ImageBase (boofcv.struct.image.ImageBase)5 ImageType (boofcv.struct.image.ImageType)5 DogArray (org.ddogleg.struct.DogArray)5