Search in sources :

Example 36 with CameraPinholeBrown

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

the class TestBundleAdjustmentOps method convert_brown_to_bundlePinhole.

@Test
void convert_brown_to_bundlePinhole() {
    var src = new CameraPinholeBrown().fsetK(1, 2, 3, 4, 5, 6, 7).fsetRadial(-1, -2).fsetTangental(0.1, 0.2);
    var dst = new BundlePinhole(true);
    assertSame(dst, BundleAdjustmentOps.convert(src, dst));
    assertFalse(dst.zeroSkew);
    assertEquals(src.fx, dst.fx);
    assertEquals(src.fy, dst.fy);
    assertEquals(src.cx, dst.cx);
    assertEquals(src.cy, dst.cy);
    assertEquals(src.skew, dst.skew);
}
Also used : BundlePinhole(boofcv.alg.geo.bundle.cameras.BundlePinhole) CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Test(org.junit.jupiter.api.Test)

Example 37 with CameraPinholeBrown

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

the class TestBundleAdjustmentOps method convert_bundleBrown_brown.

@Test
void convert_bundleBrown_brown() {
    var src = new BundlePinholeBrown().setK(2, 3, 0, 7, 3).setRadial(1, 2).setTangential(-1, -9);
    var dst = new CameraPinholeBrown().fsetK(1, 2, 3, 4, 5, 6, 7).fsetRadial(-1, -2).fsetTangental(0.1, 0.2);
    assertSame(dst, BundleAdjustmentOps.convert(src, width, height, dst));
    assertArrayEquals(src.radial, dst.radial);
    assertEquals(src.t1, dst.t1);
    assertEquals(src.t2, dst.t2);
    assertEquals(src.fx, dst.fx);
    assertEquals(src.fy, dst.fy);
    assertEquals(src.cx, dst.cx);
    assertEquals(src.cy, dst.cy);
    assertEquals(src.skew, dst.skew);
    assertEquals(width, dst.width);
    assertEquals(height, dst.height);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) BundlePinholeBrown(boofcv.alg.geo.bundle.cameras.BundlePinholeBrown) Test(org.junit.jupiter.api.Test)

Example 38 with CameraPinholeBrown

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

the class TestBundleAdjustmentOps method convert_bundleSimple_brown.

@Test
void convert_bundleSimple_brown() {
    var src = new BundlePinholeSimplified(10, 1, 2);
    var dst = new CameraPinholeBrown().fsetK(1, 2, 3, 4, 5, 6, 7).fsetRadial(-1, -2).fsetTangental(0.1, 0.2);
    assertSame(dst, BundleAdjustmentOps.convert(src, width, height, dst));
    assertArrayEquals(new double[] { src.k1, src.k2 }, dst.radial);
    assertEquals(0.0, dst.t1);
    assertEquals(0.0, dst.t2);
    assertEquals(src.f, dst.fx);
    assertEquals(src.f, dst.fy);
    assertEquals(width / 2, dst.cx);
    assertEquals(height / 2, dst.cy);
    assertEquals(0.0, dst.skew);
    assertEquals(width, dst.width);
    assertEquals(height, dst.height);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) BundlePinholeSimplified(boofcv.alg.geo.bundle.cameras.BundlePinholeSimplified) Test(org.junit.jupiter.api.Test)

Example 39 with CameraPinholeBrown

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

the class TestCalibrationIO method saveOpenCV.

/**
 * Read an actual OpenCV generated file
 */
@Test
void saveOpenCV() {
    CameraPinholeBrown model = new CameraPinholeBrown();
    model.fsetK(1, 2, 3, 4, 0.65, 100, 7);
    model.fsetRadial(.1, .2, .3);
    model.fsetTangental(0.5, 0.7);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    CalibrationIO.saveOpencv(model, new OutputStreamWriter(stream));
    CameraPinholeBrown found = CalibrationIO.loadOpenCV(new InputStreamReader(new ByteArrayInputStream(stream.toByteArray())));
    assertEquals(model.width, found.width);
    assertEquals(model.height, found.height);
    assertEquals(model.fx, found.fx, 1e-8);
    assertEquals(model.fy, found.fy, 1e-8);
    assertEquals(model.skew, found.skew, 1e-8);
    assertEquals(model.cx, found.cx, 1e-8);
    assertEquals(model.cy, found.cy, 1e-8);
    for (int i = 0; i < 3; i++) {
        assertEquals(model.radial[i], found.radial[i], 1e-8);
    }
    assertEquals(model.t1, found.t1, 1e-8);
    assertEquals(model.t2, found.t2, 1e-8);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Test(org.junit.jupiter.api.Test)

Example 40 with CameraPinholeBrown

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

the class TestCalibrationIO method loadOpenCV.

/**
 * Read an actual OpenCV generated file
 */
@Test
void loadOpenCV() {
    URL url = TestCalibrationIO.class.getResource("pinhole_distorted.yml");
    CameraPinholeBrown model = CalibrationIO.loadOpenCV(url);
    assertEquals(640, model.width);
    assertEquals(480, model.height);
    assertEquals(5.2626362816407709e+02, model.fx, 1e-8);
    assertEquals(0, model.skew, 1e-8);
    assertEquals(5.2830704330313858e+02, model.fy, 1e-8);
    assertEquals(3.1306715867053975e+02, model.cx, 1e-8);
    assertEquals(2.4747722332735930e+02, model.cy, 1e-8);
    assertEquals(3, model.radial.length);
    assertEquals(-3.7077854691489726e-01, model.radial[0], 1e-8);
    assertEquals(2.4308561956661329e-01, model.radial[1], 1e-8);
    assertEquals(-1.2351969388838037e-01, model.radial[2], 1e-8);
    assertEquals(4.4148972909019294e-04, model.t1, 1e-8);
    assertEquals(-6.0304229617877381e-04, model.t2, 1e-8);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Aggregations

CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)99 Test (org.junit.jupiter.api.Test)62 Se3_F64 (georegression.struct.se.Se3_F64)39 GrayF32 (boofcv.struct.image.GrayF32)29 Point2D_F64 (georegression.struct.point.Point2D_F64)19 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)16 LensDistortionBrown (boofcv.alg.distort.brown.LensDistortionBrown)14 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)14 BufferedImage (java.awt.image.BufferedImage)14 ArrayList (java.util.ArrayList)12 CameraPinhole (boofcv.struct.calib.CameraPinhole)11 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)10 DMatrixRMaj (org.ejml.data.DMatrixRMaj)10 File (java.io.File)9 StereoParameters (boofcv.struct.calib.StereoParameters)6 GrayU8 (boofcv.struct.image.GrayU8)6 Point3D_F64 (georegression.struct.point.Point3D_F64)6 ImageBase (boofcv.struct.image.ImageBase)5 ImageType (boofcv.struct.image.ImageType)5 DogArray (org.ddogleg.struct.DogArray)5