Search in sources :

Example 41 with CameraPinhole

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

the class TestPerspectiveOps method pinholeToMatrix_class_F.

@Test
void pinholeToMatrix_class_F() {
    FMatrixRMaj K = PerspectiveOps.pinholeToMatrix(new CameraPinhole(1.0, 2, 3, 4, 5, 400, 500), (FMatrixRMaj) null);
    assertEquals(1, K.get(0, 0), UtilEjml.TEST_F32);
    assertEquals(2, K.get(1, 1), UtilEjml.TEST_F32);
    assertEquals(3, K.get(0, 1), UtilEjml.TEST_F32);
    assertEquals(4, K.get(0, 2), UtilEjml.TEST_F32);
    assertEquals(5, K.get(1, 2), UtilEjml.TEST_F32);
    assertEquals(1, K.get(2, 2), UtilEjml.TEST_F32);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 42 with CameraPinhole

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

the class TestPerspectiveOps method renderPixel_intrinsic.

@Test
void renderPixel_intrinsic() {
    Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
    CameraPinhole intrinsic = new CameraPinhole(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, null);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 43 with CameraPinhole

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

the class TestPerspectiveOps method approximatePinhole.

@Test
void approximatePinhole() {
    CameraPinhole original = PerspectiveOps.createIntrinsic(640, 480, 75, 70, null);
    LensDistortionPinhole distortion = new LensDistortionPinhole(original);
    CameraPinhole found = PerspectiveOps.approximatePinhole(distortion.undistort_F64(true, false), original.width, original.height);
    assertEquals(original.width, found.width);
    assertEquals(original.width, found.width);
    assertEquals(original.skew, found.skew, UtilEjml.TEST_F64);
    assertEquals(original.fx, found.fx, 1);
    assertEquals(original.fy, found.fy, 1);
}
Also used : LensDistortionPinhole(boofcv.alg.distort.pinhole.LensDistortionPinhole) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 44 with CameraPinhole

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

the class TestPerspectiveOps method renderPixel_SE3_homogenous.

@Test
void renderPixel_SE3_homogenous() {
    var X3 = new Point3D_F64(0.1, -0.05, 3);
    var X4 = new Point4D_F64(0.1, -0.05, 3, 1);
    X4.scale(1.2);
    Se3_F64 worldToCamera = SpecialEuclideanOps_F64.eulerXyz(0.2, 0.01, -0.03, 0.1, -0.05, 0.03, null);
    CameraPinhole intrinsic = new CameraPinhole(100, 150, 0.1, 120, 209, 500, 600);
    {
        Point2D_F64 expected = PerspectiveOps.renderPixel(worldToCamera, intrinsic, X3, null);
        Point2D_F64 found = PerspectiveOps.renderPixel(worldToCamera, intrinsic, X4, null);
        assertEquals(expected.x, found.x, 1e-8);
        assertEquals(expected.y, found.y, 1e-8);
    }
    // test to see if it can handle points at infinity. Translational component shouldn't matter
    Se3_F64 noTranslate = worldToCamera.copy();
    noTranslate.T.setTo(0, 0, 0);
    {
        X4.w = 0.0;
        Point2D_F64 expected = PerspectiveOps.renderPixel(noTranslate, intrinsic, X3, null);
        Point2D_F64 found = PerspectiveOps.renderPixel(worldToCamera, intrinsic, X4, null);
        assertEquals(expected.x, found.x, 1e-8);
        assertEquals(expected.y, found.y, 1e-8);
    }
}
Also used : CameraPinhole(boofcv.struct.calib.CameraPinhole) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 45 with CameraPinhole

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

the class TestLensDistortionOps_F64 method transformChangeModel_EXPAND.

/**
 * Checks the border of the returned transform. Makes sure that no none-visible portion is visible.
 * Also makes sure that the requested inverse transform is actually the inverse.
 */
@Test
void transformChangeModel_EXPAND() {
    CameraPinholeBrown param;
    param = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    CameraPinhole desired = new CameraPinhole(param);
    Point2Transform2_F64 adjToDist = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, param, desired, true, null);
    Point2Transform2_F64 distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, param, desired, false, null);
    checkInside(adjToDist, distToAdj);
    // distort it in the other direction
    param = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(-0.1, -1e-4);
    adjToDist = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, param, desired, true, null);
    distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, param, desired, false, null);
    checkInside(adjToDist, distToAdj);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Aggregations

CameraPinhole (boofcv.struct.calib.CameraPinhole)154 Test (org.junit.jupiter.api.Test)81 Se3_F64 (georegression.struct.se.Se3_F64)36 DMatrixRMaj (org.ejml.data.DMatrixRMaj)32 Point2D_F64 (georegression.struct.point.Point2D_F64)24 ArrayList (java.util.ArrayList)23 Point3D_F64 (georegression.struct.point.Point3D_F64)19 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)12 SceneStructureMetric (boofcv.abst.geo.bundle.SceneStructureMetric)11 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)11 Test (org.junit.Test)10 GrayF32 (boofcv.struct.image.GrayF32)9 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)8 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)8 BufferedImage (java.awt.image.BufferedImage)8 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)7 VerbosePrint (org.ddogleg.struct.VerbosePrint)7 LensDistortionPinhole (boofcv.alg.distort.pinhole.LensDistortionPinhole)6 WorldToCameraToPixel (boofcv.alg.geo.WorldToCameraToPixel)6 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5