The most common calibration object is affine and can be represented simply by a matrix K. Cal3 stores its five linear pinhole intrinsics—horizontal and vertical focal lengths, skew, and principal point—and is the common base interface for GTSAM’s richer camera calibration models.
import gtsam
import numpy as npInitialization¶
Construct from five scalars in (fx, fy, skew, px, py) order or from a five-element vector.
calibration = gtsam.Cal3(800.0, 790.0, 0.2, 320.0, 240.0)
from_vector = gtsam.Cal3(np.array([800.0, 790.0, 0.2, 320.0, 240.0]))
assert calibration.equals(from_vector, 1e-12)Properties¶
fx(), fy(), skew(), px(), and py() expose the five parameters. principalPoint() and aspectRatio() provide common derived quantities, and vector() returns the constructor order.
print("parameters:", calibration.vector())
print("principal point:", calibration.principalPoint())
print("aspect ratio fy/fx:", calibration.aspectRatio())Matrix form¶
K() returns the standard upper-triangular intrinsic matrix and inverse() returns its inverse. These are useful when converting between normalized homogeneous coordinates and pixel coordinates.
K = calibration.K()
K_inverse = calibration.inverse()
print(K)
np.testing.assert_allclose(K_inverse @ K, np.eye(3), atol=1e-12)
normalized_h = np.array([0.1, -0.05, 1.0])
pixel_h = K @ normalized_h
print("pixel coordinates:", pixel_h[:2] / pixel_h[2])Base-class role¶
Cal3 itself models only the linear intrinsic matrix and is not exposed as an optimizable manifold. Concrete classes such as Cal3_S2, Cal3DS2, and Cal3Fisheye add projection and manifold operations.
Source¶
AI assistance caveat¶
AI was used to help draft this documentation, and inaccuracies could be present.