- replace the linear search in a sorted list by the appropriate algorithm
This commit is contained in:
parent
c3e813517d
commit
28c2d3b89f
@ -159,18 +159,11 @@ const Mat DescriptorMatcher::DescriptorCollection::getDescriptor( int globalDesc
|
|||||||
|
|
||||||
void DescriptorMatcher::DescriptorCollection::getLocalIdx( int globalDescIdx, int& imgIdx, int& localDescIdx ) const
|
void DescriptorMatcher::DescriptorCollection::getLocalIdx( int globalDescIdx, int& imgIdx, int& localDescIdx ) const
|
||||||
{
|
{
|
||||||
imgIdx = -1;
|
CV_Assert( (globalDescIdx>=0) && (globalDescIdx < size()) );
|
||||||
CV_Assert( globalDescIdx < size() );
|
std::vector<int>::const_iterator img_it = std::upper_bound(startIdxs.begin(), startIdxs.end(), globalDescIdx);
|
||||||
for( size_t i = 1; i < startIdxs.size(); i++ )
|
--img_it;
|
||||||
{
|
imgIdx = img_it - startIdxs.begin();
|
||||||
if( globalDescIdx < startIdxs[i] )
|
localDescIdx = globalDescIdx - (*img_it);
|
||||||
{
|
|
||||||
imgIdx = (int)(i - 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
imgIdx = imgIdx == -1 ? (int)(startIdxs.size() - 1) : imgIdx;
|
|
||||||
localDescIdx = globalDescIdx - startIdxs[imgIdx];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DescriptorMatcher::DescriptorCollection::size() const
|
int DescriptorMatcher::DescriptorCollection::size() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user