diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index 2a6c66885c..e1c73a0bd5 100755 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -803,7 +803,12 @@ void FlannBasedMatcher::convertToDMatches( const DescriptorCollection& collectio { int imgIdx, trainIdx; collection.getLocalIdx( idx, imgIdx, trainIdx ); - matches[i].push_back( DMatch( i, trainIdx, imgIdx, std::sqrt(dists.at(i,j))) ); + float dist = 0; + if (dists.type() == CV_32S) + dist = static_cast( dists.at(i,j) ); + else + dist = std::sqrt(dists.at(i,j)); + matches[i].push_back( DMatch( i, trainIdx, imgIdx, dist ) ); } } }