Wide-angle cameras need their own bespoke calibration objects. Cal3Fisheye implements an equidistant fisheye projection with four radial coefficients for cameras whose field of view makes a perspective radial model inadequate.
import gtsam
import numpy as npInitialization¶
The explicit constructor makes the model and parameter order visible. A default constructor is also available, but calibrated values are preferable in real projection code.
calibration = gtsam.Cal3Fisheye(
420.0, 415.0, 0.0, 320.0, 240.0,
1e-2, -1e-3, 1e-4, -1e-5,
)
print(calibration)Calibration parameters¶
k1() through k4() parameterize the angle-domain distortion polynomial. vector() collects the optimized parameters, while K() returns the intrinsic matrix associated with the linear part of the model.
print("intrinsic matrix:")
print(calibration.K())
print("distortion:", [calibration.k1(), calibration.k2(),
calibration.k3(), calibration.k4()])
print("all parameters:", calibration.vector())Calibrating and uncalibrating points¶
uncalibrate() maps normalized image coordinates to pixels and applies this model’s distortion. calibrate() performs the inverse mapping iteratively. Their round trip is the most direct way to check parameter conventions.
normalized = np.array([0.12, -0.08])
pixel = calibration.uncalibrate(normalized)
recovered = calibration.calibrate(pixel)
print("pixel:", pixel)
print("recovered normalized point:", recovered)
np.testing.assert_allclose(recovered, normalized, atol=1e-7)Manifold operations¶
Calibration objects participate in nonlinear optimization through retract() and localCoordinates(). The tangent coordinates follow the order returned by vector() for the parameters that this model optimizes.
delta = np.array([1.0, -1.0, 0.01, 0.2, -0.2, 1e-5, -1e-6, 1e-7, -1e-8])
perturbed = calibration.retract(delta)
recovered_delta = calibration.localCoordinates(perturbed)
print("parameter increment:", recovered_delta)
np.testing.assert_allclose(recovered_delta, delta, atol=1e-9)