Main Content

Structure from Motion

Reconstruct 3-D scene structure from multiple views using incremental structure from motion and NeRF

Structure from motion (SfM) is the process of estimating the 3-D structure of a scene from a set of 2-D images taken from different viewpoints. Computer Vision Toolbox™ provides an end-to-end SfM pipeline, including feature detection, matching, camera pose estimation, triangulation, and bundle adjustment. These capabilities are essential for applications such as 3-D mapping, photogrammetry, and autonomous navigation.

For a step-by-step comprehensive walkthrough of an incremental structure-from-motion pipeline, see the Structure from Motion from Multiple Views example series. The example series shows how to create a view graph from camera views using the bag-of-features approach, refine the view graph using geometric constraints, initialize the 3-D reconstruction by selecting a robust initial view pair, and then integrate the rest of the camera views to reconstruct the complete 3-D scene. For information on how to use the sparse 3-D point cloud of a scene and generate a dense 3-D mesh, see the Dense 3-D Reconstruction of Asteroid Surface from Image Sequence example.

For dense reconstruction and novel view synthesis, the toolbox supports Neural Radiance Fields (NeRF). Use the trainNerfacto function to train a NeRF model on your collection of images and generate novel views. You can then use the point cloud to generate a 3-D mesh using the pc2surfacemesh (Lidar Toolbox) function.

Functions

expand all

detectSIFTFeaturesDetect scale invariant feature transform (SIFT) features (Since R2021b)
detectORBFeaturesDetect ORB keypoints
detectBRISKFeaturesDetect BRISK features
detectFASTFeaturesDetect corners using FAST algorithm
detectHarrisFeaturesDetect corners using Harris–Stephens algorithm
detectMinEigenFeaturesDetect corners using minimum eigenvalue algorithm
detectMSERFeaturesDetect MSER features
detectSURFFeaturesDetect SURF features
detectKAZEFeaturesDetect KAZE features
extractFeaturesExtract interest point descriptors
matchFeaturesFind matching features
matchFeaturesInRadiusFind matching features within specified radius
vision.PointTrackerTrack points in video using Kanade-Lucas-Tomasi (KLT) algorithm

Store Image and Camera Data

imageviewsetManage data for structure-from-motion, visual odometry, and visual SLAM
worldpointsetManage 3-D to 2-D point correspondences
cameraIntrinsicsObject for storing intrinsic camera parameters
rigidtform3d3-D rigid geometric transformation (Since R2022b)
affinetform3d3-D affine geometric transformation (Since R2022b)

Estimate Camera Poses

estimateEssentialMatrixEstimate essential matrix from corresponding points in a pair of images
estimateFundamentalMatrixEstimate fundamental matrix from corresponding points in stereo images
estworldposeEstimate camera pose from 3-D to 2-D point correspondences (Since R2022b)
estrelposeCalculate relative rotation and translation between camera poses (Since R2022b)

Triangulate Image Points

pointTrackObject for storing matching points from multiple views
findTracksFind matched points across multiple views
triangulate3-D locations of undistorted matching points in stereo images
triangulateMultiview3-D locations of world points matched across multiple images

Optimize Camera Poses and 3-D Points

bundleAdjustmentAdjust collection of 3-D points and camera poses
bundleAdjustmentMotionAdjust collection of 3-D points and camera poses using motion-only bundle adjustment
bundleAdjustmentStructureRefine 3-D points using structure-only bundle adjustment
nerfactoDense reconstruction and novel view synthesis using Nerfacto Neural Radiance Field (NeRF) model (Since R2026a)
trainNerfactoCreate and train Nerfacto Neural Radiance Field (NeRF) model (Since R2026a)
compareTrajectoriesCompare estimated trajectory against ground truth (Since R2024b)
trajectoryErrorMetricsStore accuracy metrics for trajectories (Since R2024b)
stereoAnaglyphCreate red-cyan anaglyph from stereo pair of images
pcshowPlot 3-D point cloud
plotCameraPlot camera in 3-D coordinates
showMatchedFeaturesDisplay corresponding feature points
rotmat2vec3dConvert 3-D rotation matrix to rotation vector (Since R2022b)
rotvec2mat3dConvert 3-D rotation vector to rotation matrix (Since R2022b)
quaternionCreate quaternion array (Since R2023b)

Topics

Incremental Structure from Motion

Basics

Featured Examples