fixed problem with incorrect distance values returned by FlannBasedMatcher for hamming metric (int's were interpreted as floats)

This commit is contained in:
Alexander Mordvintsev 2011-09-22 08:52:40 +00:00
parent 8b23c79294
commit 0ad1d0afac

View File

@ -803,7 +803,12 @@ void FlannBasedMatcher::convertToDMatches( const DescriptorCollection& collectio
{ {
int imgIdx, trainIdx; int imgIdx, trainIdx;
collection.getLocalIdx( idx, imgIdx, trainIdx ); collection.getLocalIdx( idx, imgIdx, trainIdx );
matches[i].push_back( DMatch( i, trainIdx, imgIdx, std::sqrt(dists.at<float>(i,j))) ); float dist = 0;
if (dists.type() == CV_32S)
dist = static_cast<float>( dists.at<int>(i,j) );
else
dist = std::sqrt(dists.at<float>(i,j));
matches[i].push_back( DMatch( i, trainIdx, imgIdx, dist ) );
} }
} }
} }