Search in sources :

Example 61 with CameraPinhole

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

the class TestSelfCalibrationLinearDualQuadratic method constructMatrix.

@Test
void constructMatrix() {
    List<CameraPinhole> intrinsics = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        intrinsics.add(new CameraPinhole(400 + i * 5, 420, 0.1, 0, 0, 0, 0));
    }
    renderGood(intrinsics);
    SelfCalibrationLinearDualQuadratic alg = new SelfCalibrationLinearDualQuadratic(false);
    addProjectives(alg);
    DMatrixRMaj L = new DMatrixRMaj(3, 3);
    alg.constructMatrix(L);
    DMatrixRMaj q = new DMatrixRMaj(10, 1);
    q.data[0] = Q.get(0, 0);
    q.data[1] = Q.get(0, 1);
    q.data[2] = Q.get(0, 2);
    q.data[3] = Q.get(0, 3);
    q.data[4] = Q.get(1, 1);
    q.data[5] = Q.get(1, 2);
    q.data[6] = Q.get(1, 3);
    q.data[7] = Q.get(2, 2);
    q.data[8] = Q.get(2, 3);
    q.data[9] = Q.get(3, 3);
    // double[] sv = SingularOps_DDRM.singularValues(L);
    // for (int i = 0; i < sv.length; i++) {
    // System.out.println("sv["+i+"] = "+sv[i]);
    // }
    DMatrixRMaj found = new DMatrixRMaj(L.numRows, 1);
    // See if it's the null space
    CommonOps_DDRM.mult(L, q, found);
    assertEquals(0, NormOps_DDRM.normF(found), 10 * UtilEjml.TEST_F64);
}
Also used : ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 62 with CameraPinhole

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

the class TestSelfCalibrationLinearRotationSingle method performTest.

private void performTest(CameraPinhole intrinsic) {
    // compute planes at infinity
    List<Homography2D_F64> homographies = new ArrayList<>();
    for (int i = 0; i < listP.size(); i++) {
        DMatrixRMaj P = listP.get(i);
        Equation eq = new Equation();
        eq.alias(P, "P", planeAtInfinity, "p");
        eq.process("H = P(:,0:2) - P(:,3)*p'");
        Homography2D_F64 H = new Homography2D_F64();
        DConvertMatrixStruct.convert(eq.lookupDDRM("H"), H);
        homographies.add(H);
    }
    SelfCalibrationLinearRotationSingle alg = new SelfCalibrationLinearRotationSingle();
    CameraPinhole found = new CameraPinhole();
    assertTrue(alg.estimate(homographies, found));
    assertEquals(intrinsic.fx, found.fx, UtilEjml.TEST_F64_SQ);
    assertEquals(intrinsic.fy, found.fy, UtilEjml.TEST_F64_SQ);
    assertEquals(intrinsic.cx, found.cx, UtilEjml.TEST_F64_SQ);
    assertEquals(intrinsic.cy, found.cy, UtilEjml.TEST_F64_SQ);
    assertEquals(intrinsic.skew, found.skew, UtilEjml.TEST_F64_SQ);
}
Also used : ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Homography2D_F64(georegression.struct.homography.Homography2D_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole)

Example 63 with CameraPinhole

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

the class TestSelfCalibrationLinearRotationSingle method stationary.

/**
 * This should fail because there isn't enough visual motion
 */
@Test
void stationary() {
    CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 450, 475, 0, 0);
    renderStationary(intrinsic);
    checkFailure();
}
Also used : CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 64 with CameraPinhole

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

the class TestSelfCalibrationLinearRotationSingle method two_axis.

@Test
void two_axis() {
    CameraPinhole intrinsic = new CameraPinhole(400, 420, 0.1, 450, 475, 0, 0);
    renderRotateTwoAxis(intrinsic);
    performTest(intrinsic);
}
Also used : CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 65 with CameraPinhole

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

the class TestSelfCalibrationLinearRotationSingle method checkFailure.

private void checkFailure() {
    // compute planes at infinity
    List<Homography2D_F64> homographies = new ArrayList<>();
    for (int i = 0; i < listP.size(); i++) {
        DMatrixRMaj P = listP.get(i);
        Equation eq = new Equation();
        eq.alias(P, "P", planeAtInfinity, "p");
        eq.process("H = P(:,0:2) - P(:,3)*p'");
        Homography2D_F64 H = new Homography2D_F64();
        DConvertMatrixStruct.convert(eq.lookupDDRM("H"), H);
        homographies.add(H);
    }
    SelfCalibrationLinearRotationSingle alg = new SelfCalibrationLinearRotationSingle();
    CameraPinhole found = new CameraPinhole();
    assertFalse(alg.estimate(homographies, found));
}
Also used : ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Equation(org.ejml.equation.Equation) Homography2D_F64(georegression.struct.homography.Homography2D_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole)

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