Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VLAD Similarity Evaluation #1255

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions corelib/src/Signature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,37 @@ void Signature::removeVirtualLinks()

float Signature::compareTo(const Signature & s) const
{
UASSERT(this->sensorData().globalDescriptors().size() == s.sensorData().globalDescriptors().size());

float similarity = 0.0f;
const std::multimap<int, int> & words = s.getWords();
int totalDescs = 0;

for(size_t i=0; i<this->sensorData().globalDescriptors().size(); ++i)
{
if(this->sensorData().globalDescriptors()[i].type()==1 && s.sensorData().globalDescriptors()[i].type()==1)
{
similarity += this->sensorData().globalDescriptors()[i].data().dot(s.sensorData().globalDescriptors()[i].data());
totalDescs += 1;
}
}

if(!s.isBadSignature() && !this->isBadSignature())
if(totalDescs)
{
std::list<std::pair<int, std::pair<int, int> > > pairs;
int totalWords = ((int)_words.size()-_invalidWordsCount)>((int)words.size()-s.getInvalidWordsCount())?((int)_words.size()-_invalidWordsCount):((int)words.size()-s.getInvalidWordsCount());
UASSERT(totalWords > 0);
EpipolarGeometry::findPairs(words, _words, pairs);
similarity /= totalDescs;
}
else
{
const std::multimap<int, int> & words = s.getWords();

similarity = float(pairs.size()) / float(totalWords);
if(!s.isBadSignature() && !this->isBadSignature())
{
std::list<std::pair<int, std::pair<int, int> > > pairs;
int totalWords = ((int)_words.size()-_invalidWordsCount)>((int)words.size()-s.getInvalidWordsCount())?((int)_words.size()-_invalidWordsCount):((int)words.size()-s.getInvalidWordsCount());
UASSERT(totalWords > 0);
EpipolarGeometry::findPairs(words, _words, pairs);

similarity = float(pairs.size()) / float(totalWords);
}
}
return similarity;
}
Expand Down
Loading