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.

SfmTrack2d

Created by Codex.

Represent one structure-from-motion (SfM) landmark track as camera-indexed two-dimensional observations.

Open In Colab

Mathematical idea

A two-dimensional track is an indexed observation set

Tj2D={(i,zij)},zijR2,\mathcal T_j^{2D}=\{(i,z_{ij})\},\qquad z_{ij}\in\mathbb R^2,

where image index ii may occur at most once. Triangulation later associates these measurements with one three-dimensional landmark PjP_j.

import gtsam
import numpy as np

from gtsam import symbol_shorthand

C = symbol_shorthand.C
K = symbol_shorthand.K
P = symbol_shorthand.P
S = symbol_shorthand.S
X = symbol_shorthand.X

Core operations

Each measurement is (camera_index, Point2). measurementMatrix() returns an N x 2 array and indexVector() returns the corresponding camera indices. siftIndex() uses the legacy Scale-Invariant Feature Transform (SIFT) name for the feature position within the track; it is not an external feature identifier.

track = gtsam.SfmTrack2d()
track.addMeasurement(0, np.array([320.0, 240.0]))
track.addMeasurement(2, np.array([301.5, 241.0]))

print("measurements:", track.numberMeasurements())
print("camera indices:", track.indexVector())
print("image points:")
print(track.measurementMatrix())
print("unique cameras:", track.hasUniqueCameras())
measurements: 2
camera indices: [0 2]
image points:
[[320.  240. ]
 [301.5 241. ]]
unique cameras: True

Practical notes

Camera indices refer to positions in an SfmData camera list, not arbitrary GTSAM keys. Use gtsam.gtsfm.tracksFromPairwiseMatches to assemble tracks from pairwise feature matches.