Search in sources :

Example 51 with CameraPinhole

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

the class TestPRnPDirectLinearTransform method many_perfect.

/**
 * No noise. Redundant data
 */
@Test
void many_perfect() {
    Se3_F64 m = SpecialEuclideanOps_F64.eulerXyz(0.01, 0.1, 1, 0.01, -0.02, 0.015, null);
    DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(new CameraPinhole(500, 500, 0, 250, 250, 1000, 1000), (DMatrixRMaj) null);
    PRnPDirectLinearTransform alg = new PRnPDirectLinearTransform();
    DMatrixRMaj P = PerspectiveOps.createCameraMatrix(m.R, m.T, K, null);
    for (int trial = 0; trial < 5; trial++) {
        generateScene(40 - trial, P, false);
        DMatrixRMaj found = new DMatrixRMaj(3, 4);
        assertTrue(alg.process(worldPts, pixelsView2, found));
        CommonOps_DDRM.divide(P, NormOps_DDRM.normF(P));
        CommonOps_DDRM.divide(found, NormOps_DDRM.normF(found));
        if (Math.signum(P.get(0, 0)) != Math.signum(found.get(0, 0))) {
            CommonOps_DDRM.scale(-1, found);
        }
        assertTrue(MatrixFeatures_DDRM.isIdentical(P, found, UtilEjml.TEST_F64));
    }
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) CameraPinhole(boofcv.struct.calib.CameraPinhole) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 52 with CameraPinhole

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

the class CommonAutoCalibrationChecks method renderTranslationOnly.

public void renderTranslationOnly(CameraPinhole camera) {
    List<CameraPinhole> cameras = new ArrayList<>();
    for (int i = 0; i < 11; i++) {
        Se3_F64 R = new Se3_F64();
        Se3_F64 axis = new Se3_F64();
        axis.T.z = -2 + rand.nextGaussian() * 0.01;
        axis.T.x = rand.nextGaussian() * 0.4;
        axis.T.y = rand.nextGaussian() * 0.4;
        Se3_F64 cameraToWorld = new Se3_F64();
        R.concat(axis, cameraToWorld);
        listCameraToWorld.add(cameraToWorld);
        cameras.add(camera);
    }
    render(cameras);
}
Also used : ArrayList(java.util.ArrayList) CameraPinhole(boofcv.struct.calib.CameraPinhole) Se3_F64(georegression.struct.se.Se3_F64)

Example 53 with CameraPinhole

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

the class CommonThreeViewSelfCalibration method standardScene.

protected void standardScene() {
    cameraA = new CameraPinhole(600, 600, 0.1, 400, 410, 800, 600);
    cameraB = cameraC = cameraA;
    list_world_to_cameras = new ArrayList<>();
    list_world_to_cameras.add(eulerXyz(0, 0, -2, 0, 0, 0.0, null).invert(null));
    list_world_to_cameras.add(eulerXyz(1, 0.1, -2.1, -0.1, 0, 0.05, null).invert(null));
    list_world_to_cameras.add(eulerXyz(0.1, 1, -1.9, 0, 0.05, 0.0, null).invert(null));
}
Also used : CameraPinhole(boofcv.struct.calib.CameraPinhole)

Example 54 with CameraPinhole

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

the class TestRefineTwoViewPinholeRotation method evaluateImperfect.

private void evaluateImperfect(CameraPinhole intrinsic1, CameraPinhole intrinsic2, List<AssociatedPair> pairs) {
    var alg = new RefineTwoViewPinholeRotation();
    // Apply some constraints. Yes this test isn't exhaustive at all.
    alg.assumeUnityAspect = true;
    alg.zeroSkew = true;
    alg.assumeSameIntrinsics = false;
    alg.knownFocalLength = false;
    // Focal length and rotation are going to be way off as a test
    CameraPinhole found1 = new CameraPinhole(200, 200, 0.0, 530, 530, 1000, 1000);
    CameraPinhole found2 = new CameraPinhole(1000, 1000, 0.0, 430, 430, 800, 800);
    DMatrixRMaj R = CommonOps_DDRM.identity(3);
    alg.converge.maxIterations = 40;
    // alg.setVerbose(System.out, null);
    assertTrue(alg.refine(pairs, R, found1, found2));
    // Should be significantly better
    assertTrue(alg.errorAfter * 1e5 <= alg.errorBefore);
    // Check constraints
    assertEquals(found1.fx, found1.fy);
    assertEquals(found2.fx, found2.fy);
    assertEquals(0.0, found1.skew);
    assertEquals(0.0, found2.skew);
    // Based on manual inspection there seems to be redundancy in these equations some place that I've
    // not yet dug out. The error is zero but K1 and K2 are significantly different. R is "close"
    // very crude test for focal length
    assertEquals(intrinsic1.fx, found1.fx, 150);
    assertEquals(intrinsic2.fx, found2.fy, 150);
    // Compute the number of radians different the two rotations are
    DMatrixRMaj diffR = CommonOps_DDRM.multTransA(view1_to_view2.R, R, null);
    double angle = ConvertRotation3D_F64.matrixToRodrigues(diffR, null).theta;
    assertEquals(0.0, angle, 0.05);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) CameraPinhole(boofcv.struct.calib.CameraPinhole)

Example 55 with CameraPinhole

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

the class TestRefineTwoViewPinholeRotation method imperfectInput_perfectObservations.

/**
 * Intrinsic parameters are not correct, but the model will match. No noise added to observations.
 */
@Test
void imperfectInput_perfectObservations() {
    CameraPinhole intrinsic1 = new CameraPinhole(400, 400, 0.0, 500, 550, 1000, 1000);
    CameraPinhole intrinsic2 = new CameraPinhole(600, 600, 0.0, 400, 440, 800, 800);
    List<AssociatedPair> pairs = renderPairs(intrinsic1, intrinsic2, 100, 0.0);
    evaluateImperfect(intrinsic1, intrinsic2, pairs);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) 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