GTSAM’s smart projection factors constrain sets of cameras. CameraSet<CAMERA> provides the ordered camera collection they use, and Python exposes concrete list-like containers for each wrapped pinhole, spherical, and stereo camera family.
import gtsam
import numpy as npCreating a camera set¶
Choose the container whose suffix matches the camera calibration. CameraSetCal3_S2 accepts PinholeCameraCal3_S2 instances and retains each camera’s pose and calibration.
K = gtsam.Cal3_S2(800.0, 800.0, 0.0, 320.0, 240.0)
camera0 = gtsam.PinholeCameraCal3_S2(gtsam.Pose3(), K)
camera1 = gtsam.PinholeCameraCal3_S2(
gtsam.Pose3(gtsam.Rot3(), np.array([1.0, 0.0, 0.0])), K
)
cameras = gtsam.CameraSetCal3_S2([camera0, camera1])
print("number of cameras:", len(cameras))Container operations¶
The wrapped set behaves like a Python sequence. Use indexing and iteration to read cameras, and append(), extend(), insert(), pop(), or clear() to modify it. Mixing camera families is rejected by the wrapper type.
point = np.array([0.2, -0.1, 5.0])
measurements = [camera.project(point) for camera in cameras]
for index, measurement in enumerate(measurements):
print(index, measurement)Available specializations¶
The wrapper provides camera sets for Cal3_S2, Cal3DS2, Cal3Unified, Cal3Bundler, Cal3Fisheye, spherical cameras, and stereo cameras. Backward-compatible names such as CameraSetCal3_S2 refer to the corresponding pinhole-camera specialization.
Source¶
AI assistance caveat¶
AI was used to help draft this documentation, and inaccuracies could be present.