FlannBasedMatcher(LshIndex) in the feature2d optimization for continuance additional train()
Current implementation of miniflann is releasing the trained index, and rebuilding the index from the beginning. But, some indexing algorithms like the LSH are able to add the indexing data after that. This branch is implementation of that optimization for LshIndex FlannBasedMatcher in the feature2d.
This commit is contained in:
@@ -531,10 +531,20 @@ void FlannBasedMatcher::clear()
|
||||
|
||||
void FlannBasedMatcher::train()
|
||||
{
|
||||
if( flannIndex.empty() || mergedDescriptors.size() < addedDescCount )
|
||||
int trained = mergedDescriptors.size();
|
||||
if (flannIndex.empty() || trained < addedDescCount)
|
||||
{
|
||||
mergedDescriptors.set( trainDescCollection );
|
||||
flannIndex = new flann::Index( mergedDescriptors.getDescriptors(), *indexParams );
|
||||
|
||||
// construct flannIndex class, if empty or Algorithm not equal FLANN_INDEX_LSH
|
||||
if (flannIndex.empty() || flannIndex->getAlgorithm() != cvflann::FLANN_INDEX_LSH)
|
||||
{
|
||||
flannIndex = new flann::Index(mergedDescriptors.getDescriptors(), *indexParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
flannIndex->build(mergedDescriptors.getDescriptors(), mergedDescriptors.getDescriptors().rowRange(trained, mergedDescriptors.size()), *indexParams, cvflann::FLANN_DIST_HAMMING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user