Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

CameraSet

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.

Open In Colab
import gtsam
import numpy as np

Creating 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

CameraSet.h

AI assistance caveat

AI was used to help draft this documentation, and inaccuracies could be present.