Main Content

Visual SLAM

Real-time visual localization and mapping (vSLAM) with monocular, RGB-D, or stereo cameras and inertial sensor fusion with deployment support

Visual simultaneous localization and mapping (vSLAM) is the process of estimating the position and orientation of a camera while simultaneously building a map of its environment using visual inputs. Computer Vision Toolbox™ supports vSLAM workflows for monocular, RGB-D, and stereo cameras, with optional inertial sensor fusion for improved accuracy. These capabilities are essential for applications in robotics, augmented reality, and autonomous navigation. For guidance on choosing a vSLAM workflow, see Choose SLAM Workflow Based on Sensor Data.

Each visual SLAM object—monovslam, rgbdvslam, and stereovslam—provides ready-to-use tools to add frames, track keyframes, compute 3-D map points, estimate camera poses, close loops, and visualize data throughout the camera trajectory. You can also evaluate the performance of the vSLAM algorithm by comparing the estimated camera trajectory to the ground truth using the compareTrajectories function. The toolbox also provides functionality for building your own visual SLAM pipeline.

You can use the toolbox to perform code generation and deployment of vSLAM algorithms. For more information, see Build and Deploy Visual SLAM Algorithm with ROS in MATLAB and Performant and Deployable Monocular Visual SLAM.

Functions

expand all

monovslamVisual simultaneous localization and mapping (vSLAM) and visual-inertial sensor fusion with monocular camera (Since R2023b)
addFrameAdd image frame to visual SLAM object (Since R2023b)
hasNewKeyFrameCheck if new key frame added in visual SLAM object (Since R2023b)
checkStatusCheck status of visual SLAM object (Since R2023b)
isDoneEnd-of-file status (logical)
mapPointsBuild 3-D map of world points (Since R2023b)
posesAbsolute camera poses of key frames (Since R2023b)
plotPlot 3-D map points and estimated camera trajectory in visual SLAM (Since R2023b)
resetReset visual SLAM object (Since R2023b)
rgbdvslamFeature-based visual simultaneous localization and mapping (vSLAM) and visual-inertial sensor fusion with RGB-D camera (Since R2024a)
addFrameAdd pair of color and depth images to RGB-D visual SLAM object (Since R2024a)
hasNewKeyFrameCheck if new key frame added in RGB-D visual SLAM object (Since R2024a)
checkStatusCheck status of visual RGB-D SLAM object (Since R2024a)
isDoneEnd-of-processing status for RGB-D visual SLAM object (Since R2024a)
mapPointsBuild 3-D map of world points from RGB-D vSLAM object (Since R2024a)
posesAbsolute camera poses of RGB-D vSLAM key frames (Since R2024a)
plotPlot 3-D map points and estimated camera trajectory in RGB-D visual SLAM (Since R2024a)
resetReset RGB-D visual SLAM object (Since R2024a)
stereovslamFeature-based visual simultaneous localization and mapping (vSLAM) and visual-inertial sensor fusion with stereo camera (Since R2024a)
addFrameAdd pair of color and depth images to stereo visual SLAM object (Since R2024a)
hasNewKeyFrameCheck if new key frame added in stereo visual SLAM object (Since R2024a)
checkStatusCheck status of stereo visual SLAM object (Since R2024a)
isDoneEnd-of-processing status for stereo visual SLAM object (Since R2024a)
mapPointsBuild 3-D map of world points from stereo vSLAM object (Since R2024a)
posesAbsolute camera poses of stereo key frames (Since R2024a)
plotPlot 3-D map points and estimated camera trajectory in stereo visual SLAM (Since R2024a)
resetReset stereo visual SLAM object (Since R2024a)
compareTrajectoriesCompare estimated trajectory against ground truth (Since R2024b)
trajectoryErrorMetricsStore accuracy metrics for trajectories (Since R2024b)
imshowDisplay image
showMatchedFeaturesDisplay corresponding feature points
plotPlot image view set views and connections
plotCameraPlot camera in 3-D coordinates
pcshowPlot 3-D point cloud
pcplayerVisualize streaming 3-D point cloud data

Detect, Extract, and Match Features

detectSURFFeaturesDetect SURF features
detectORBFeaturesDetect ORB keypoints
extractFeaturesExtract interest point descriptors
matchFeaturesFind matching features
matchFeaturesInRadiusFind matching features within specified radius

Reconstruct 3-D Structure

triangulate3-D locations of undistorted matching points in stereo images
img2world2dDetermine world coordinates of image points (Since R2022b)
world2imgProject world points into image (Since R2022b)

Estimate Motion

estgeotform2dEstimate 2-D geometric transformation from matching point pairs (Since R2022b)
estgeotform3dEstimate 3-D geometric transformation from matching point pairs (Since R2022b)
estimateFundamentalMatrixEstimate fundamental matrix from corresponding points in stereo images
estworldposeEstimate camera pose from 3-D to 2-D point correspondences (Since R2022b)
findWorldPointsInViewFind world points observed in view
findWorldPointsInTracksFind world points that correspond to point tracks
estrelposeCalculate relative rotation and translation between camera poses (Since R2022b)

Optimize Motion and 3-D Structure

optimizePosesOptimize absolute poses using relative pose constraints
createPoseGraphCreate pose graph
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

Loop Closure

bagOfFeaturesBag of visual words object
bagOfFeaturesDBoWBag of visual words using DBoW2 library (Since R2024b)
dbowLoopDetectorDetect loop closure using visual features (Since R2024b)
indexImagesCreate image search index
invertedImageIndexSearch index that maps visual words to images

Manage Data

imageviewsetManage data for structure-from-motion, visual odometry, and visual SLAM
worldpointsetManage 3-D to 2-D point correspondences

Transformations

se3SE(3) homogeneous transformation (Since R2026a)
so3SO(3) rotation (Since R2026a)

Topics

Ready-To-Use Visual SLAM Functions

Build Your Own Visual SLAM Pipeline

Featured Examples