Created by Codex.
Represent one structure-from-motion (SfM) landmark track as camera-indexed two-dimensional observations.
Mathematical idea¶
A two-dimensional track is an indexed observation set
where image index may occur at most once. Triangulation later associates these measurements with one three-dimensional landmark .
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.XCore 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.