use of boofcv.alg.geo.calibration.cameras.Zhang99Camera in project BoofCV by lessthanoptimal.
the class GenericCalibrationZhang99 method optimizedParam_noisy.
void optimizedParam_noisy(double noiseMagnitude) {
for (CameraConfig config : createCamera(rand)) {
CalibInputs inputs = createInputs(config.model, 3, rand);
Zhang99Camera zhangCamera = createGenerator(config, inputs.layout);
// Add noise to the initial pinhole camera estimate
DMatrixRMaj K = cameraToK(config);
K.data[0] += (rand.nextDouble() - 0.5) * noiseMagnitude;
K.data[4] += (rand.nextDouble() - 0.5) * noiseMagnitude;
var alg = new CalibrationPlanarGridZhang99(inputs.layout, zhangCamera);
alg.convertIntoBundleStructure(inputs.worldToViews, K, inputs.homographies, inputs.observations);
assertTrue(alg.performBundleAdjustment());
// verify results using errors
List<ImageResults> errors = alg.computeErrors();
for (int i = 0; i < errors.size(); i++) {
assertEquals(0, errors.get(i).meanError, 0.01);
}
}
}
use of boofcv.alg.geo.calibration.cameras.Zhang99Camera in project BoofCV by lessthanoptimal.
the class GenericCalibrationZhang99 method fullTest.
void fullTest(boolean partial) {
for (CameraConfig config : createCamera(rand)) {
CalibInputs inputs = createInputs(config.model, 3, rand);
// remove points for partial visibility of a target
if (partial) {
for (int i = 0; i < inputs.observations.size(); i++) {
CalibrationObservation o = inputs.observations.get(i);
for (int j = 0; j < 5; j++) {
o.points.remove(rand.nextInt(o.points.size()));
}
}
}
Zhang99Camera zhangCamera = createGenerator(config, inputs.layout);
CalibrationPlanarGridZhang99 alg = new CalibrationPlanarGridZhang99(inputs.layout, zhangCamera);
// estimate camera parameters using full non-linear methods
alg.process(inputs.observations);
// verify results using errors
List<ImageResults> errors = alg.computeErrors();
for (int i = 0; i < errors.size(); i++) {
assertEquals(0, errors.get(i).meanError, reprojectionTol);
}
}
}
use of boofcv.alg.geo.calibration.cameras.Zhang99Camera in project BoofCV by lessthanoptimal.
the class GenericCalibrationZhang99 method linearEstimate.
/**
* See how well it computes an initial guess at the parameters given perfect inputs
*/
@Test
public void linearEstimate() {
for (CameraConfig config : createCameraForLinearTests(rand)) {
CalibInputs inputs = createInputs(config.model, 3, rand);
Zhang99Camera zhangCamera = createGenerator(config, inputs.layout);
var alg = new CalibrationPlanarGridZhang99(inputs.layout, zhangCamera);
alg.setZeroSkew(true);
alg.linearEstimate(inputs.observations);
SceneStructureMetric structure = alg.getStructure();
CM found = (CM) zhangCamera.getCameraModel(structure.getCameras().get(0).model);
checkIntrinsicOnly(config.model, found, 0.01, 0.1, 0.1);
}
}
Aggregations