Search in sources :

Example 6 with CameraKannalaBrandt

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

the class TestCalibrationIO method save_load_KannalaBrandt.

void save_load_KannalaBrandt(CameraKannalaBrandt model) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    CalibrationIO.save(model, new OutputStreamWriter(stream));
    CameraKannalaBrandt found = CalibrationIO.load(new StringReader(stream.toString()));
    assertTrue(model.isIdentical(found));
}
Also used : CameraKannalaBrandt(boofcv.struct.calib.CameraKannalaBrandt)

Example 7 with CameraKannalaBrandt

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

the class TestBundleKannalaBrandt method jacobian_ZeroSkew.

/**
 * Check the Jacobian when skew is set to zero
 */
@Test
void jacobian_ZeroSkew() {
    CameraKannalaBrandt model = new CameraKannalaBrandt().fsetK(500, 550, 0.0, 600, 650);
    model.fsetSymmetric(1.0, 0.4).fsetRadial(1.1, 0.2, -0.05).fsetTangent(0.5, -0.1, 0.06).fsetRadialTrig(0.01, 0.02, -0.03, 0.12).fsetTangentTrig(0.01, 0.2, 0.1, 0.4);
    BundleKannalaBrandt alg = new BundleKannalaBrandt(model);
    // sanity check
    assertTrue(alg.isZeroSkew());
    double[] parameters = new double[alg.getIntrinsicCount()];
    alg.getIntrinsic(parameters, 0);
    new GenericChecksBundleAdjustmentCamera(alg, 0.01) {
    }.setParameters(new double[][] { parameters }).checkAll();
}
Also used : CameraKannalaBrandt(boofcv.struct.calib.CameraKannalaBrandt) Test(org.junit.jupiter.api.Test)

Example 8 with CameraKannalaBrandt

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

the class TestBundleKannalaBrandt method encode_decode.

/**
 * Makes sure parameterization is consistent
 */
@Test
void encode_decode() {
    CameraKannalaBrandt model = new CameraKannalaBrandt().fsetK(500, 550, 0.01, 600, 650);
    model.fsetSymmetric(1.0, 0.4).fsetRadial(1.1, 0.2, -0.01).fsetTangent(0.5, -0.1, 0.06).fsetRadialTrig(0.01, 0.02, -0.03, 0.12).fsetTangentTrig(0.01, 0.2, 0.1, 0.4);
    BundleKannalaBrandt alg = new BundleKannalaBrandt(model);
    // Get the parameters
    double[] parameters = new double[alg.getIntrinsicCount() + 4];
    alg.getIntrinsic(parameters, 2);
    // Discard the old and encode. See if it has the expected results
    alg = new BundleKannalaBrandt();
    alg.configure(false, 2, 3);
    alg.setIntrinsic(parameters, 2);
    assertTrue(model.isIdentical(alg.model));
}
Also used : CameraKannalaBrandt(boofcv.struct.calib.CameraKannalaBrandt) Test(org.junit.jupiter.api.Test)

Example 9 with CameraKannalaBrandt

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

the class TestKannalaBrandtStoP_F64 method onlySymmetric.

/**
 * Qualitative checks for when there's only symmetric distortion
 */
@Test
void onlySymmetric() {
    // different symmetric coefficient that has a known behavior to the distortion
    CameraKannalaBrandt fish1 = new CameraKannalaBrandt().fsetK(500, 550, 0.0, 600, 650).fsetSymmetric(1.0, 0.1);
    CameraKannalaBrandt fish2 = new CameraKannalaBrandt().fsetK(500, 550, 0.0, 600, 650).fsetSymmetric(1.0, 0.4);
    Point2D_F64 pixel1 = new Point2D_F64();
    Point2D_F64 pixel2 = new Point2D_F64();
    // rotate around the circle. This should work in every direction
    for (int i = 0; i < 20; i++) {
        double theta = Math.PI * 2.0 * i / 20.0;
        double r = 0.5;
        double x = r * Math.cos(theta);
        double y = r * Math.sin(theta);
        Point3D_F64 P3 = new Point3D_F64(x, y, 0.8);
        new KannalaBrandtStoP_F64(fish1).compute(P3.x, P3.y, P3.z, pixel1);
        new KannalaBrandtStoP_F64(fish2).compute(P3.x, P3.y, P3.z, pixel2);
        pixel1.x -= (double) fish1.cx;
        pixel1.y -= (double) fish1.cy;
        pixel2.x -= (double) fish2.cx;
        pixel2.y -= (double) fish2.cy;
        // NOTE: The norm changes because fx != fy
        // System.out.printf("angle=%.3f (%.2f %.2f) n=%.2f %.2f\n", theta, x,y,pixel1.norm(), pixel2.norm());
        // larger positive coefficients should push points out farther in the radial direction
        assertTrue(pixel1.norm() < pixel2.norm());
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) CameraKannalaBrandt(boofcv.struct.calib.CameraKannalaBrandt) Test(org.junit.jupiter.api.Test)

Example 10 with CameraKannalaBrandt

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

the class TestKannalaBrandtStoP_F64 method doesItBlowUp.

/**
 * pass in variable parameter lengths and see if bad stuff happens
 */
@Test
void doesItBlowUp() {
    List<CameraKannalaBrandt> models = new ArrayList<>();
    models.add(new CameraKannalaBrandt().fsetK(500, 550, 0.0, 600, 650));
    models.add(new CameraKannalaBrandt().fsetK(500, 550, 0.1, 600, 650));
    models.add(new CameraKannalaBrandt().fsetK(500, 550, 0.0, 600, 650).fsetSymmetric(1.0, 0.1));
    models.add(new CameraKannalaBrandt().fsetK(500, 550, 0.0, 600, 650).fsetRadial(1.0, 0.1));
    models.add(new CameraKannalaBrandt().fsetK(500, 550, 0.0, 600, 650).fsetTangent(1.0, 0.1));
    models.add(new CameraKannalaBrandt().fsetK(500, 550, 0.0, 600, 650).fsetSymmetric(1.0, 0.1).fsetRadial(1.0, 0.1).fsetTangent(1.0, 0.1));
    Point3D_F64 P3 = new Point3D_F64(0.1, -0.05, 0.8);
    Point2D_F64 pixel = new Point2D_F64();
    for (CameraKannalaBrandt camera : models) {
        new KannalaBrandtStoP_F64(camera).compute(P3.x, P3.y, P3.z, pixel);
        assertFalse(UtilEjml.isUncountable(pixel.normSq()));
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) CameraKannalaBrandt(boofcv.struct.calib.CameraKannalaBrandt) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

CameraKannalaBrandt (boofcv.struct.calib.CameraKannalaBrandt)11 Test (org.junit.jupiter.api.Test)10 Point2D_F64 (georegression.struct.point.Point2D_F64)5 Point3D_F64 (georegression.struct.point.Point3D_F64)4 Point3Transform2_F64 (boofcv.struct.distort.Point3Transform2_F64)1 ArrayList (java.util.ArrayList)1 FunctionNtoM (org.ddogleg.optimization.functions.FunctionNtoM)1 FunctionNtoMxN (org.ddogleg.optimization.functions.FunctionNtoMxN)1 DMatrix2x2 (org.ejml.data.DMatrix2x2)1 DMatrixRMaj (org.ejml.data.DMatrixRMaj)1