41 useDistanceL1_(
false),
42 rebalancingFactor_(2.0
f)
117 unsigned long memoryUsage =
sizeof(
FlannIndex);
118 memoryUsage +=
addedDescriptors_.size() * (
sizeof(int) +
sizeof(cv::Mat) +
sizeof(std::map<int, cv::Mat>::iterator)) +
sizeof(std::map<int, cv::Mat>);
119 memoryUsage +=
sizeof(std::list<int>) +
removedIndexes_.size() *
sizeof(int);
143 const cv::Mat & features,
145 float rebalancingFactor)
150 UASSERT(features.type() == CV_32FC1 || features.type() == CV_8UC1);
158 if(featuresType_ == CV_8UC1)
188 for(
int i=0; i<features.rows; ++i)
203 const cv::Mat & features,
206 float rebalancingFactor)
211 UASSERT(features.type() == CV_32FC1 || features.type() == CV_8UC1);
219 if(featuresType_ == CV_8UC1)
249 for(
int i=0; i<features.rows; ++i)
264 const cv::Mat & features,
268 float rebalancingFactor)
273 UASSERT(features.type() == CV_32FC1 || features.type() == CV_8UC1);
281 if(featuresType_ == CV_8UC1)
311 for(
int i=0; i<features.rows; ++i)
326 const cv::Mat & features,
327 unsigned int table_number,
328 unsigned int key_size,
329 unsigned int multi_probe_level,
330 float rebalancingFactor)
335 UASSERT(features.type() == CV_8UC1);
349 for(
int i=0; i<features.rows; ++i)
372 UERROR(
"Flann index not yet created!");
373 return std::vector<unsigned int>();
377 bool indexRebuilt =
false;
378 size_t removedPts = 0;
392 indexRebuilt = index->
removedCount() == 0 && removedPts>0;
409 indexRebuilt = index->
removedCount() == 0 && removedPts>0;
423 indexRebuilt = index->
removedCount() == 0 && removedPts>0;
437 indexRebuilt = index->
removedCount() == 0 && removedPts>0;
454 std::vector<unsigned int> indexes;
455 for(
int i=0; i<features.rows; ++i)
468 UERROR(
"Flann index not yet created!");
498 const cv::Mat & query,
508 UERROR(
"Flann index not yet created!");
511 indices.create(query.rows, knn,
sizeof(
size_t)==8?CV_64F:CV_32S);
512 dists.create(query.rows, knn,
featuresType_ == CV_8UC1?CV_32S:CV_32F);
544 const cv::Mat & query,
545 std::vector<std::vector<size_t> > & indices,
546 std::vector<std::vector<float> > & dists,
555 UERROR(
"Flann index not yet created!");
564 std::vector<std::vector<unsigned int> > distsF;
567 dists.resize(distsF.size());
568 for(
unsigned int i=0; i<dists.size(); ++i)
570 dists[i].resize(distsF[i].size());
571 for(
unsigned int j=0; j<distsF[i].size(); ++j)
573 dists[i][j] = (float)distsF[i][j];
void knnSearch(const cv::Mat &query, cv::Mat &indices, cv::Mat &dists, int knn, int checks=32, float eps=0.0, bool sorted=true) const
void removePoint(unsigned int index)
void buildLSHIndex(const cv::Mat &features, unsigned int table_number=12, unsigned int key_size=20, unsigned int multi_probe_level=2, float rebalancingFactor=2.0f)
std::map< int, cv::Mat > addedDescriptors_
void radiusSearch(const cv::Mat &query, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< float > > &dists, float radius, int maxNeighbors=0, int checks=32, float eps=0.0, bool sorted=true) const
#define UASSERT(condition)
void buildLinearIndex(const cv::Mat &features, bool useDistanceL1=false, float rebalancingFactor=2.0f)
unsigned long memoryUsed() const
void addPoints(const Matrix< ElementType > &points, float rebuild_threshold=2)
void buildKDTreeSingleIndex(const cv::Mat &features, int leafMaxSize=10, bool reorder=true, bool useDistanceL1=false, float rebalancingFactor=2.0f)
unsigned int indexedFeatures() const
ULogger class and convenient macros.
std::vector< unsigned int > addPoints(const cv::Mat &features)
void buildKDTreeIndex(const cv::Mat &features, int trees=4, bool useDistanceL1=false, float rebalancingFactor=2.0f)
size_t removedCount() const
std::list< int > removedIndexes_
size_t sizeAtBuild() const