Overview
TheTracking class is responsible for processing incoming frames, estimating camera pose, and deciding when to create new keyframes. It performs feature extraction, matching, relocalization, and local map tracking.
Constructor
Parameters
pSys: Pointer to the System objectpVoc: Pointer to ORB vocabulary for place recognitionpFrameDrawer: Pointer to frame drawer for visualizationpMapDrawer: Pointer to map drawer for visualizationpAtlas: Pointer to Atlas (multi-map manager)pKFDB: Pointer to KeyFrame databasestrSettingPath: Path to settings configuration filesensor: Sensor type (MONOCULAR, STEREO, RGBD, etc.)settings: Pointer to Settings object_nameSeq: Optional sequence name
Enumerations
eTrackingState
Defines the current tracking state:SYSTEM_NOT_READY: System is initializingNO_IMAGES_YET: No frames received yetNOT_INITIALIZED: Waiting for initializationOK: Tracking successfullyRECENTLY_LOST: Tracking lost recently, attempting recoveryLOST: Tracking lost, performing relocalizationOK_KLT: Tracking with KLT optical flow
Image Processing Methods
GrabImageMonocular
im: Input image (RGB or grayscale)timestamp: Image timestampfilename: Optional filename for debugging
GrabImageStereo
imRectLeft: Left rectified imageimRectRight: Right rectified imagetimestamp: Image timestampfilename: Optional filename for debugging
GrabImageRGBD
imRGB: RGB imageimD: Depth map (CV_32F)timestamp: Image timestampfilename: Optional filename for debugging
GrabImuData
imuMeasurement: IMU data point (acceleration and angular velocity)
Configuration Methods
SetLocalMapper
SetLoopClosing
SetViewer
ChangeCalibration
strSettingPath: Path to new calibration file
Mode Control
InformOnlyTracking
flag: True for localization-only, false for full SLAM
SetStepByStep
GetStepByStep
State Management
Reset
bLocMap: If true, resets local mapping as well
ResetActiveMap
bLocMap: If true, resets local mapping as well
CreateMapInAtlas
Information Retrieval
GetLastKeyFrame
GetMatchesInliers
GetLocalMapMPS
GetImageScale
GetNumberDataset
IMU Methods
UpdateFrameIMU
s: Scale factorb: IMU biaspCurrentKeyFrame: Reference keyframe
Debugging and Logging
SaveSubTrajectory
strNameFile_frames: Filename for frame trajectorystrNameFile_kf: Filename for keyframe trajectorystrFolder: Optional output folderpMap: Optional specific map to save
NewDataset
Configuration Parsing
ParseCamParamFile
ParseORBParamFile
ParseIMUParamFile
Public Member Variables
State Variables
Frame Data
Trajectory Information
Tracking Flags
Usage Example
Tracking Pipeline
The internal tracking pipeline follows these steps:- Feature Extraction: Extract ORB features from the input image
- Initial Pose Estimation:
- If initialized: Use motion model or reference keyframe
- If not initialized: Perform initialization
- Track Local Map: Match features with local map points
- Pose Optimization: Optimize camera pose using matched points
- Keyframe Decision: Decide if a new keyframe should be created
- Update Local Map: Update local keyframes and map points
Thread Safety
The Tracking class runs in the main thread and communicates with other threads (Local Mapping, Loop Closing) through thread-safe queues and mutexes.Related Classes
- System - Main SLAM system interface
- LocalMapping - Local map optimization
- LoopClosing - Loop detection and global optimization