42 unique_lock<mutex> lock(
mMutex);
44 for(DBoW2::BowVector::const_iterator vit= pKF->
mBowVec.begin(), vend=pKF->
mBowVec.end(); vit!=vend; vit++)
50 unique_lock<mutex> lock(
mMutex);
53 for(DBoW2::BowVector::const_iterator vit=pKF->
mBowVec.begin(), vend=pKF->
mBowVec.end(); vit!=vend; vit++)
58 for(list<KeyFrame*>::iterator lit=lKFs.begin(), lend= lKFs.end(); lit!=lend; lit++)
79 list<KeyFrame*> lKFsSharingWords;
84 unique_lock<mutex> lock(
mMutex);
86 for(DBoW2::BowVector::const_iterator vit=pKF->
mBowVec.begin(), vend=pKF->
mBowVec.end(); vit != vend; vit++)
90 for(list<KeyFrame*>::iterator lit=lKFs.begin(), lend= lKFs.end(); lit!=lend; lit++)
96 if(!spConnectedKeyFrames.count(pKFi))
99 lKFsSharingWords.push_back(pKFi);
107 if(lKFsSharingWords.empty())
108 return vector<KeyFrame*>();
110 list<pair<float,KeyFrame*> > lScoreAndMatch;
113 int maxCommonWords=0;
114 for(list<KeyFrame*>::iterator lit=lKFsSharingWords.begin(), lend= lKFsSharingWords.end(); lit!=lend; lit++)
116 if((*lit)->mnLoopWords>maxCommonWords)
117 maxCommonWords=(*lit)->mnLoopWords;
120 int minCommonWords = maxCommonWords*0.8f;
125 for(list<KeyFrame*>::iterator lit=lKFsSharingWords.begin(), lend= lKFsSharingWords.end(); lit!=lend; lit++)
137 lScoreAndMatch.push_back(make_pair(si,pKFi));
141 if(lScoreAndMatch.empty())
142 return vector<KeyFrame*>();
144 list<pair<float,KeyFrame*> > lAccScoreAndMatch;
145 float bestAccScore = minScore;
148 for(list<pair<float,KeyFrame*> >::iterator it=lScoreAndMatch.begin(), itend=lScoreAndMatch.end(); it!=itend; it++)
153 float bestScore = it->first;
154 float accScore = it->first;
156 for(vector<KeyFrame*>::iterator vit=vpNeighs.begin(), vend=vpNeighs.end(); vit!=vend; vit++)
170 lAccScoreAndMatch.push_back(make_pair(accScore,pBestKF));
171 if(accScore>bestAccScore)
172 bestAccScore=accScore;
176 float minScoreToRetain = 0.75f*bestAccScore;
178 set<KeyFrame*> spAlreadyAddedKF;
179 vector<KeyFrame*> vpLoopCandidates;
180 vpLoopCandidates.reserve(lAccScoreAndMatch.size());
182 for(list<pair<float,KeyFrame*> >::iterator it=lAccScoreAndMatch.begin(), itend=lAccScoreAndMatch.end(); it!=itend; it++)
184 if(it->first>minScoreToRetain)
187 if(!spAlreadyAddedKF.count(pKFi))
189 vpLoopCandidates.push_back(pKFi);
190 spAlreadyAddedKF.insert(pKFi);
196 return vpLoopCandidates;
201 list<KeyFrame*> lKFsSharingWords;
205 unique_lock<mutex> lock(
mMutex);
207 for(DBoW2::BowVector::const_iterator vit=F->
mBowVec.begin(), vend=F->
mBowVec.end(); vit != vend; vit++)
211 for(list<KeyFrame*>::iterator lit=lKFs.begin(), lend= lKFs.end(); lit!=lend; lit++)
218 lKFsSharingWords.push_back(pKFi);
224 if(lKFsSharingWords.empty())
225 return vector<KeyFrame*>();
228 int maxCommonWords=0;
229 for(list<KeyFrame*>::iterator lit=lKFsSharingWords.begin(), lend= lKFsSharingWords.end(); lit!=lend; lit++)
231 if((*lit)->mnRelocWords>maxCommonWords)
232 maxCommonWords=(*lit)->mnRelocWords;
235 int minCommonWords = maxCommonWords*0.8f;
237 list<pair<float,KeyFrame*> > lScoreAndMatch;
242 for(list<KeyFrame*>::iterator lit=lKFsSharingWords.begin(), lend= lKFsSharingWords.end(); lit!=lend; lit++)
251 lScoreAndMatch.push_back(make_pair(si,pKFi));
255 if(lScoreAndMatch.empty())
256 return vector<KeyFrame*>();
258 list<pair<float,KeyFrame*> > lAccScoreAndMatch;
259 float bestAccScore = 0;
262 for(list<pair<float,KeyFrame*> >::iterator it=lScoreAndMatch.begin(), itend=lScoreAndMatch.end(); it!=itend; it++)
267 float bestScore = it->first;
268 float accScore = bestScore;
270 for(vector<KeyFrame*>::iterator vit=vpNeighs.begin(), vend=vpNeighs.end(); vit!=vend; vit++)
284 lAccScoreAndMatch.push_back(make_pair(accScore,pBestKF));
285 if(accScore>bestAccScore)
286 bestAccScore=accScore;
290 float minScoreToRetain = 0.75f*bestAccScore;
291 set<KeyFrame*> spAlreadyAddedKF;
292 vector<KeyFrame*> vpRelocCandidates;
293 vpRelocCandidates.reserve(lAccScoreAndMatch.size());
294 for(list<pair<float,KeyFrame*> >::iterator it=lAccScoreAndMatch.begin(), itend=lAccScoreAndMatch.end(); it!=itend; it++)
296 const float &si = it->first;
297 if(si>minScoreToRetain)
300 if(!spAlreadyAddedKF.count(pKFi))
302 vpRelocCandidates.push_back(pKFi);
303 spAlreadyAddedKF.insert(pKFi);
308 return vpRelocCandidates;
312 template<
class Archive>
318 unique_lock<mutex> lock_InvertedFile(
mMutex);
std::vector< KeyFrame * > GetBestCovisibilityKeyFrames(const int &N)
double score(const BowVector &a, const BowVector &b) const
std::vector< KeyFrame * > DetectRelocalizationCandidates(Frame *F)
std::set< KeyFrame * > GetConnectedKeyFrames()
std::vector< list< KeyFrame * > > mvInvertedFile
void erase(KeyFrame *pKF)
long unsigned int mnLoopQuery
long unsigned int mnRelocQuery
void serialize(Archive &ar, const unsigned int version)
virtual unsigned int size() const
std::vector< KeyFrame * > DetectLoopCandidates(KeyFrame *pKF, float minScore)
const ORBVocabulary * mpVoc