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.

CalibratedCamera

CalibratedCamera is the variable type to use when camera calibration is known exactly and the only unknowns are the camera’s position and attitude. It is a six-degree-of-freedom pinhole camera that operates directly in normalized image coordinates.

Open In Colab
import gtsam
import numpy as np

Creating a camera

The camera stores a Pose3. The identity pose places the camera at the world origin looking along its positive z-axis.

pose = gtsam.Pose3(gtsam.Rot3.Yaw(0.1), np.array([1.0, 0.0, 0.0]))
camera = gtsam.CalibratedCamera(pose)
print("camera center:", camera.pose().translation())

Projection and backprojection

project(point) returns (x/z, y/z) in the camera frame. backproject(measurement, depth) follows that ray to the requested camera-frame depth.

point = np.array([2.0, 0.5, 4.0])
measurement = camera.project(point)
depth = camera.pose().transformTo(point)[2]
recovered = camera.backproject(measurement, depth)
print("normalized measurement:", measurement)
np.testing.assert_allclose(recovered, point, atol=1e-9)

Geometry and manifold operations

range() computes distance to a point, pose, or camera. retract() and localCoordinates() expose the six-dimensional camera-pose manifold. Level() is a convenient factory for lifting a planar pose to a level camera at a specified height.

level_camera = gtsam.CalibratedCamera.Level(gtsam.Pose2(2.0, 3.0, 0.2), 1.5)
print("level camera center:", level_camera.pose().translation())
print("range to point:", camera.range(point))

Source

CalibratedCamera.h

AI assistance caveat

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