MCPcopy Create free account
hub / github.com/UZ-SLAMLab/ORB_SLAM3 / Relocalization

Method Relocalization

src/Tracking.cc:3609–3777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3607}
3608
3609bool Tracking::Relocalization()
3610{
3611 Verbose::PrintMess("Starting relocalization", Verbose::VERBOSITY_NORMAL);
3612 // Compute Bag of Words Vector
3613 mCurrentFrame.ComputeBoW();
3614
3615 // Relocalization is performed when tracking is lost
3616 // Track Lost: Query KeyFrame Database for keyframe candidates for relocalisation
3617 vector<KeyFrame*> vpCandidateKFs = mpKeyFrameDB->DetectRelocalizationCandidates(&mCurrentFrame, mpAtlas->GetCurrentMap());
3618
3619 if(vpCandidateKFs.empty()) {
3620 Verbose::PrintMess("There are not candidates", Verbose::VERBOSITY_NORMAL);
3621 return false;
3622 }
3623
3624 const int nKFs = vpCandidateKFs.size();
3625
3626 // We perform first an ORB matching with each candidate
3627 // If enough matches are found we setup a PnP solver
3628 ORBmatcher matcher(0.75,true);
3629
3630 vector<MLPnPsolver*> vpMLPnPsolvers;
3631 vpMLPnPsolvers.resize(nKFs);
3632
3633 vector<vector<MapPoint*> > vvpMapPointMatches;
3634 vvpMapPointMatches.resize(nKFs);
3635
3636 vector<bool> vbDiscarded;
3637 vbDiscarded.resize(nKFs);
3638
3639 int nCandidates=0;
3640
3641 for(int i=0; i<nKFs; i++)
3642 {
3643 KeyFrame* pKF = vpCandidateKFs[i];
3644 if(pKF->isBad())
3645 vbDiscarded[i] = true;
3646 else
3647 {
3648 int nmatches = matcher.SearchByBoW(pKF,mCurrentFrame,vvpMapPointMatches[i]);
3649 if(nmatches<15)
3650 {
3651 vbDiscarded[i] = true;
3652 continue;
3653 }
3654 else
3655 {
3656 MLPnPsolver* pSolver = new MLPnPsolver(mCurrentFrame,vvpMapPointMatches[i]);
3657 pSolver->SetRansacParameters(0.99,10,300,6,0.5,5.991); //This solver needs at least 6 points
3658 vpMLPnPsolvers[i] = pSolver;
3659 nCandidates++;
3660 }
3661 }
3662 }
3663
3664 // Alternatively perform some iterations of P4P RANSAC
3665 // Until we found a camera pose supported by enough inliers
3666 bool bMatch = false;

Callers

nothing calls this directly

Calls 13

GetCurrentMapMethod · 0.80
SearchByBoWMethod · 0.80
SearchByProjectionMethod · 0.80
ComputeBoWMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
isBadMethod · 0.45
SetRansacParametersMethod · 0.45
iterateMethod · 0.45
SetPoseMethod · 0.45

Tested by

no test coverage detected