fixed #1795
This commit is contained in:
parent
97835a8f32
commit
9d764b4115
@ -1605,25 +1605,20 @@ struct BatchDistInvoker
|
|||||||
// we handle both CV_32S and CV_32F cases with a single branch
|
// we handle both CV_32S and CV_32F cases with a single branch
|
||||||
int* distptr = (int*)dist->ptr(i);
|
int* distptr = (int*)dist->ptr(i);
|
||||||
|
|
||||||
int k, k0, k0_, j;
|
int j, k;
|
||||||
for( k0 = 0; k0 < K; k0++ )
|
|
||||||
if( nidxptr[k0] < 0 )
|
|
||||||
break;
|
|
||||||
k0_ = std::max(k0, 1);
|
|
||||||
|
|
||||||
for( j = 0; j < src2->rows; j++ )
|
for( j = 0; j < src2->rows; j++ )
|
||||||
{
|
{
|
||||||
int d = bufptr[j];
|
int d = bufptr[j];
|
||||||
if( d < distptr[k0_-1] )
|
if( d < distptr[K-1] )
|
||||||
{
|
{
|
||||||
for( k = std::min(k0-1, K-2); k >= 0 && distptr[k] > d; k-- )
|
for( k = K-2; k >= 0 && distptr[k] > d; k-- )
|
||||||
{
|
{
|
||||||
nidxptr[k+1] = nidxptr[k];
|
nidxptr[k+1] = nidxptr[k];
|
||||||
distptr[k+1] = distptr[k];
|
distptr[k+1] = distptr[k];
|
||||||
}
|
}
|
||||||
nidxptr[k+1] = j + update;
|
nidxptr[k+1] = j + update;
|
||||||
distptr[k+1] = d;
|
distptr[k+1] = d;
|
||||||
k0_ = k0 = std::min(k0 + 1, K);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch>
|
|||||||
vector<DMatch>& mq = matches.back();
|
vector<DMatch>& mq = matches.back();
|
||||||
mq.reserve(knn);
|
mq.reserve(knn);
|
||||||
|
|
||||||
for( int k = 0; k < knn; k++ )
|
for( int k = 0; k < nidx.cols; k++ )
|
||||||
{
|
{
|
||||||
if( nidxptr[k] < 0 )
|
if( nidxptr[k] < 0 )
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user