Brute force implementation had issues with the type of distances it was storing.
Rectified this, hopefully.
This commit is contained in:
parent
cac2e9bc80
commit
40c05d8418
@ -1808,7 +1808,7 @@ inline void bfKnnMatchImpl( BruteForceMatcher<Distance>& matcher,
|
|||||||
size_t imgCount = matcher.trainDescCollection.size();
|
size_t imgCount = matcher.trainDescCollection.size();
|
||||||
vector<Mat> allDists( imgCount ); // distances between one query descriptor and all train descriptors
|
vector<Mat> allDists( imgCount ); // distances between one query descriptor and all train descriptors
|
||||||
for( size_t i = 0; i < imgCount; i++ )
|
for( size_t i = 0; i < imgCount; i++ )
|
||||||
allDists[i] = Mat( 1, matcher.trainDescCollection[i].rows, queryDescs.type() );
|
allDists[i] = Mat( 1, matcher.trainDescCollection[i].rows, DataType<DistanceType>::type );
|
||||||
|
|
||||||
for( int qIdx = 0; qIdx < queryDescs.rows; qIdx++ )
|
for( int qIdx = 0; qIdx < queryDescs.rows; qIdx++ )
|
||||||
{
|
{
|
||||||
@ -1836,7 +1836,7 @@ inline void bfKnnMatchImpl( BruteForceMatcher<Distance>& matcher,
|
|||||||
{
|
{
|
||||||
const ValueType* d2 = (const ValueType*)(matcher.trainDescCollection[iIdx].data +
|
const ValueType* d2 = (const ValueType*)(matcher.trainDescCollection[iIdx].data +
|
||||||
matcher.trainDescCollection[iIdx].step*tIdx);
|
matcher.trainDescCollection[iIdx].step*tIdx);
|
||||||
allDists[iIdx].at<ValueType>(0, tIdx) = matcher.distance(d1, d2, dimension);
|
allDists[iIdx].at<DistanceType>(0, tIdx) = matcher.distance(d1, d2, dimension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1847,6 +1847,7 @@ inline void bfKnnMatchImpl( BruteForceMatcher<Distance>& matcher,
|
|||||||
for( int k = 0; k < knn; k++ )
|
for( int k = 0; k < knn; k++ )
|
||||||
{
|
{
|
||||||
DMatch bestMatch;
|
DMatch bestMatch;
|
||||||
|
bestMatch.distance = std::numeric_limits<DistanceType>::max();
|
||||||
for( size_t iIdx = 0; iIdx < imgCount; iIdx++ )
|
for( size_t iIdx = 0; iIdx < imgCount; iIdx++ )
|
||||||
{
|
{
|
||||||
double minVal;
|
double minVal;
|
||||||
@ -1858,9 +1859,10 @@ inline void bfKnnMatchImpl( BruteForceMatcher<Distance>& matcher,
|
|||||||
if( bestMatch.trainIdx == -1 )
|
if( bestMatch.trainIdx == -1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
allDists[bestMatch.imgIdx].at<ValueType>(0, bestMatch.trainIdx) = std::numeric_limits<DistanceType>::max();
|
allDists[bestMatch.imgIdx].at<DistanceType>(0, bestMatch.trainIdx) = std::numeric_limits<DistanceType>::max();
|
||||||
curMatches->push_back( bestMatch );
|
curMatches->push_back( bestMatch );
|
||||||
}
|
}
|
||||||
|
//TODO should already be sorted at this point?
|
||||||
std::sort( curMatches->begin(), curMatches->end() );
|
std::sort( curMatches->begin(), curMatches->end() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user