Search in sources :

Example 56 with CameraPinhole

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

the class TestRefineTwoViewPinholeRotation method perfectInput.

/**
 * Give it perfect input and see if it screws things up
 */
@Test
void perfectInput() {
    CameraPinhole intrinsic1 = new CameraPinhole(400, 410, 0.1, 500, 550, 1000, 1000);
    CameraPinhole intrinsic2 = new CameraPinhole(600, 550, 0.02, 400, 440, 800, 800);
    List<AssociatedPair> pairs = renderPairs(intrinsic1, intrinsic2, 50, 0.0);
    var alg = new RefineTwoViewPinholeRotation();
    // turn off all assumptions
    alg.assumeUnityAspect = false;
    alg.zeroSkew = false;
    alg.assumeSameIntrinsics = false;
    CameraPinhole found1 = new CameraPinhole(intrinsic1);
    CameraPinhole found2 = new CameraPinhole(intrinsic2);
    DMatrixRMaj R = view1_to_view2.R.copy();
    assertTrue(alg.refine(pairs, R, found1, found2));
    // Score shouldn't get worse, but since the input is perfect it might not get better
    assertTrue(alg.errorAfter <= alg.errorBefore);
    // should be very very similar
    assertTrue(found1.isEquals(intrinsic1, 1e-6));
    assertTrue(found2.isEquals(intrinsic2, 1e-6));
    assertTrue(MatrixFeatures_DDRM.isIdentical(view1_to_view2.R, R, 1e-6));
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) DMatrixRMaj(org.ejml.data.DMatrixRMaj) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 57 with CameraPinhole

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

the class TestSelfCalibrationLinearDualQuadratic method geometry_no_rotation.

@Test
void geometry_no_rotation() {
    CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 0, 0, 0, 0);
    renderTranslationOnly(intrinsic);
    SelfCalibrationLinearDualQuadratic alg = new SelfCalibrationLinearDualQuadratic(false);
    addProjectives(alg);
    assertEquals(GeometricResult.GEOMETRY_POOR, alg.solve());
}
Also used : CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 58 with CameraPinhole

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

the class TestSelfCalibrationLinearDualQuadratic method solve_ZeroCP_ZSkew.

@Test
void solve_ZeroCP_ZSkew() {
    List<CameraPinhole> intrinsics = new ArrayList<>();
    for (int i = 0; i < 4; i++) {
        intrinsics.add(new CameraPinhole(400 + i * 5, 420, 0, 0, 0, 0, 0));
    }
    checkSolve(intrinsics, false, true, 4);
}
Also used : ArrayList(java.util.ArrayList) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 59 with CameraPinhole

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

the class TestSelfCalibrationLinearDualQuadratic method geometry_no_translation.

@Test
void geometry_no_translation() {
    CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 0, 0, 0, 0);
    renderRotationOnly(intrinsic);
    SelfCalibrationLinearDualQuadratic alg = new SelfCalibrationLinearDualQuadratic(false);
    addProjectives(alg);
    assertEquals(GeometricResult.GEOMETRY_POOR, alg.solve());
}
Also used : CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 60 with CameraPinhole

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

the class TestSelfCalibrationLinearDualQuadratic method solveWithTrificalInput.

/**
 * Create a trifocal tensor, extract camera matrices, and see if it can find the solution
 */
@Test
void solveWithTrificalInput() {
    CameraPinhole intrinsic = new CameraPinhole(500, 500, 0, 0, 0, 0, 0);
    List<CameraPinhole> intrinsics = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        intrinsics.add(intrinsic);
    }
    renderGood(intrinsics);
    List<AssociatedTriple> obs = new ArrayList<>();
    for (int i = 0; i < cloud.size(); i++) {
        Point3D_F64 X = cloud.get(i);
        AssociatedTriple t = new AssociatedTriple();
        t.p1 = PerspectiveOps.renderPixel(listCameraToWorld.get(0), intrinsic, X, null);
        t.p2 = PerspectiveOps.renderPixel(listCameraToWorld.get(1), intrinsic, X, null);
        t.p3 = PerspectiveOps.renderPixel(listCameraToWorld.get(2), intrinsic, X, null);
        obs.add(t);
    }
    ConfigTrifocal config = new ConfigTrifocal();
    config.which = EnumTrifocal.LINEAR_7;
    Estimate1ofTrifocalTensor estimate = FactoryMultiView.trifocal_1(config);
    TrifocalTensor tensor = new TrifocalTensor();
    assertTrue(estimate.process(obs, tensor));
    DMatrixRMaj P1 = CommonOps_DDRM.identity(3, 4);
    DMatrixRMaj P2 = new DMatrixRMaj(3, 4);
    DMatrixRMaj P3 = new DMatrixRMaj(3, 4);
    MultiViewOps.trifocalToCameraMatrices(tensor, P2, P3);
    SelfCalibrationLinearDualQuadratic alg = new SelfCalibrationLinearDualQuadratic(1.0);
    alg.addCameraMatrix(P1);
    alg.addCameraMatrix(P2);
    alg.addCameraMatrix(P3);
    assertEquals(GeometricResult.SUCCESS, alg.solve());
    FastAccess<Intrinsic> found = alg.getIntrinsics();
    assertEquals(3, found.size());
    for (int i = 0; i < found.size(); i++) {
        Intrinsic f = found.get(i);
        assertEquals(500, f.fx, UtilEjml.TEST_F64_SQ);
        assertEquals(500, f.fy, UtilEjml.TEST_F64_SQ);
        assertEquals(0, f.skew, UtilEjml.TEST_F64_SQ);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) ConfigTrifocal(boofcv.factory.geo.ConfigTrifocal) Estimate1ofTrifocalTensor(boofcv.abst.geo.Estimate1ofTrifocalTensor) TrifocalTensor(boofcv.struct.geo.TrifocalTensor) ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj) CameraPinhole(boofcv.struct.calib.CameraPinhole) AssociatedTriple(boofcv.struct.geo.AssociatedTriple) Estimate1ofTrifocalTensor(boofcv.abst.geo.Estimate1ofTrifocalTensor) Intrinsic(boofcv.alg.geo.selfcalib.SelfCalibrationLinearDualQuadratic.Intrinsic) 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