75 template<
typename Distance>
91 nnIndex_ = load_saved_index(features, get_param<std::string>(
params,
"filename"), distance);
96 nnIndex_ = create_index_by_type<Distance>(index_type, features,
params, distance);
108 nnIndex_ = load_saved_index(features, get_param<std::string>(
params,
"filename"), distance);
113 nnIndex_ = create_index_by_type<Distance>(index_type, features,
params, distance);
118 Index(
const Index& other) : loaded_(other.loaded_), index_params_(other.index_params_)
120 nnIndex_ = other.nnIndex_->
clone();
170 return nnIndex_->
getPoint(point_id);
179 FILE* fout = fopen(
filename.c_str(),
"wb");
192 return nnIndex_->
veclen();
200 return nnIndex_->
size();
272 std::vector< std::vector<size_t> >& indices,
273 std::vector<std::vector<DistanceType> >& dists,
290 std::vector< std::vector<int> >& indices,
291 std::vector<std::vector<DistanceType> >& dists,
344 std::vector< std::vector<size_t> >& indices,
345 std::vector<std::vector<DistanceType> >& dists,
362 std::vector< std::vector<int> >& indices,
363 std::vector<std::vector<DistanceType> >& dists,
373 FILE* fin = fopen(
filename.c_str(),
"rb");
379 throw FLANNException(
"Datatype of saved index is different than of the one to be loaded.");
383 params[
"algorithm"] = header.h.index_type;
384 IndexType* nnIndex = create_index_by_type<Distance>(header.h.index_type, dataset,
params, distance);
386 nnIndex->loadIndex(fin);
392 void swap(
Index& other)
396 std::swap(index_params_, other.index_params_);
423 template <
typename Distance>
double Distance(const Point3D< Real > &p1, const Point3D< Real > &p2)
cmdLineReadable * params[]
virtual int usedMemory() const =0
virtual void saveIndex(FILE *stream)=0
virtual flann_algorithm_t getType() const =0
IndexParams getParameters() const
int knnSearch(const Matrix< ElementType > &queries, std::vector< std::vector< int > > &indices, std::vector< std::vector< DistanceType > > &dists, size_t knn, const SearchParams ¶ms) const
int knnSearch(const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, size_t knn, const SearchParams ¶ms) const
Perform k-nearest neighbor search.
int radiusSearch(const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams ¶ms) const
Perform radius search.
void save(std::string filename)
NNIndex< Distance > IndexType
void addPoints(const Matrix< ElementType > &points, float rebuild_threshold=2)
Distance::ElementType ElementType
Index & operator=(Index other)
int knnSearch(const Matrix< ElementType > &queries, Matrix< int > &indices, Matrix< DistanceType > &dists, size_t knn, const SearchParams ¶ms) const
void buildIndex(const Matrix< ElementType > &points)
ElementType * getPoint(size_t point_id)
Index(const IndexParams ¶ms, Distance distance=Distance())
int radiusSearch(const Matrix< ElementType > &queries, std::vector< std::vector< int > > &indices, std::vector< std::vector< DistanceType > > &dists, float radius, const SearchParams ¶ms) const
Index(const Index &other)
int radiusSearch(const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, float radius, const SearchParams ¶ms) const
Perform radius search.
void removePoint(size_t point_id)
Distance::ResultType DistanceType
flann_algorithm_t getType() const
int knnSearch(const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, size_t knn, const SearchParams ¶ms) const
Perform k-nearest neighbor search.
Index(const Matrix< ElementType > &features, const IndexParams ¶ms, Distance distance=Distance())
int radiusSearch(const Matrix< ElementType > &queries, Matrix< int > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams ¶ms) const
int getClusterCenters(Matrix< DistanceType > ¢ers)
virtual void buildIndex()
static void setLevel(int level)
virtual int knnSearch(const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, size_t knn, const SearchParams ¶ms) const
Perform k-nearest neighbor search.
virtual void removePoint(size_t id)
int radiusSearch(const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams ¶ms) const
Perform radius search.
virtual void addPoints(const Matrix< ElementType > &points, float rebuild_threshold=2)
Incrementally add points to the index.
IndexParams getParameters() const
virtual ElementType * getPoint(size_t id)
virtual void buildIndex()
virtual NNIndex * clone() const =0
IndexHeader load_header(FILE *stream)
int hierarchicalClustering(const Matrix< typename Distance::ElementType > &points, Matrix< typename Distance::ResultType > ¢ers, const KMeansIndexParams ¶ms, Distance d=Distance())
void log_verbosity(int level)
std::map< std::string, any > IndexParams
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
SavedIndexParams(std::string filename)
static const flann_datatype_t value