31 #ifndef RTABMAP_FLANN_COMPOSITE_INDEX_H_ 32 #define RTABMAP_FLANN_COMPOSITE_INDEX_H_ 52 (*this)[
"trees"] = trees;
54 (*this)[
"branching"] = branching;
56 (*this)[
"iterations"] = iterations;
58 (*this)[
"centers_init"] = centers_init;
60 (*this)[
"cb_index"] = cb_index;
70 template <
typename Distance>
97 Distance d = Distance()) : BaseClass(params,
d)
104 kmeans_index_(other.kmeans_index_), kdtree_index_(other.kdtree_index_)
116 delete kdtree_index_;
117 delete kmeans_index_;
138 return kdtree_index_->size();
146 return kdtree_index_->veclen();
154 return kmeans_index_->usedMemory() + kdtree_index_->usedMemory();
163 Logger::info(
"Building kmeans tree...\n");
164 kmeans_index_->buildIndex();
165 Logger::info(
"Building kdtree tree...\n");
166 kdtree_index_->buildIndex();
171 kmeans_index_->addPoints(points, rebuild_threshold);
172 kdtree_index_->addPoints(points, rebuild_threshold);
177 kmeans_index_->removePoint(index);
178 kdtree_index_->removePoint(index);
188 kmeans_index_->saveIndex(stream);
189 kdtree_index_->saveIndex(stream);
198 kmeans_index_->loadIndex(stream);
199 kdtree_index_->loadIndex(stream);
207 kmeans_index_->findNeighbors(result, vec, searchParams);
208 kdtree_index_->findNeighbors(result, vec, searchParams);
239 #endif //FLANN_COMPOSITE_INDEX_H_
std::map< std::string, any > IndexParams
CompositeIndexParams(int trees=4, int branching=32, int iterations=11, flann_centers_init_t centers_init=FLANN_CENTERS_RANDOM, float cb_index=0.2)
void findNeighbors(ResultSet< DistanceType > &result, const ElementType *vec, const SearchParams &searchParams) const
Method that searches for nearest-neighbours.
void saveIndex(FILE *stream)
Saves the index to a stream.
BaseClass * clone() const
void addPoints(const Matrix< ElementType > &points, float rebuild_threshold=2)
Incrementally add points to the index.
bool needs_kdtree_distance
Distance::ResultType DistanceType
Distance::ElementType ElementType
flann_algorithm_t getType() const
CompositeIndex(const Matrix< ElementType > &inputData, const IndexParams ¶ms=CompositeIndexParams(), Distance d=Distance())
void swap(CompositeIndex &other)
CompositeIndex(const CompositeIndex &other)
NNIndex< Distance > BaseClass
CompositeIndex(const IndexParams ¶ms=CompositeIndexParams(), Distance d=Distance())
void removePoint(size_t index)
void loadIndex(FILE *stream)
Loads the index from a stream.
void buildIndex()
Builds the index.
CompositeIndex & operator=(CompositeIndex other)
KMeansIndex< Distance > * kmeans_index_
virtual ~CompositeIndex()
KDTreeIndex< Distance > * kdtree_index_