ORB-SLAM3 Relocalization 2

发布时间:2026/7/25 1:42:34
ORB-SLAM3 Relocalization 2 Tracking::Relocalization()是ORB-SLAM3在跟踪丢失后尝试“找回”自身位置的核心函数。它利用词袋模型(BoW)进行图像检索,并使用MLPnP算法进行位姿估计,是系统鲁棒性的重要保障。下面是该函数在ORB-SLAM3中的完整代码与详细解读。📝 完整代码cppbool Tracking::Relocalization() { // Step 1: 计算当前帧的词袋向量 mCurrentFrame.ComputeBoW(); // Step 2: 在关键帧数据库中检测重定位候选关键帧 vectorKeyFrame* vpCandidateKFs = mpKeyFrameDB-DetectRelocalizationCandidates(mCurrentFrame, mpAtlas-GetCurrentMap()); if(vpCandidateKFs.empty()) return false; const int nKFs = vpCandidateKFs.size(); // Step 3: 对每个候选关键帧,进行词袋匹配,并创建MLPnP求解器 ORBmatcher matcher(0.75, true); vectorMLPnPsolver* vpPnPsolvers; vpPnPsolvers.resize(nKFs); vectorvectorMapPoint* vvpMapPointMatches; vvpMap