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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations