Skip to content

Commit

Permalink
Fixed inf loop when all signatures are loaded in WM and if a signatur…
Browse files Browse the repository at this point in the history
…e has a -1 word
  • Loading branch information
matlabbe committed Apr 4, 2017
1 parent aa37ac6 commit e415dd8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion corelib/src/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,27 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)

// Now load the dictionary if we have a connection
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit("Loading dictionary..."));
UDEBUG("Loading dictionary...");
if(loadAllNodesInWM)
{
UDEBUG("load all referenced words in working memory");
// load all referenced words in working memory
std::set<int> wordIds;
const std::map<int, Signature *> & signatures = this->getSignatures();
for(std::map<int, Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
{
const std::multimap<int, cv::KeyPoint> & words = i->second->getWords();
std::list<int> keys = uUniqueKeys(words);
for(std::list<int>::iterator iter=keys.begin(); iter!=keys.end();)
for(std::list<int>::iterator iter=keys.begin(); iter!=keys.end(); ++iter)
{
if(*iter > 0)
{
wordIds.insert(*iter);
}
}
}

UDEBUG("load words %d", (int)wordIds.size());
if(wordIds.size())
{
std::list<VisualWord*> words;
Expand All @@ -272,6 +276,7 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
}
else
{
UDEBUG("load words");
// load the last dictionary
_dbDriver->load(_vwd);
}
Expand Down

0 comments on commit e415dd8

Please sign in to comment.