ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
flann::LshIndex< Distance > Class Template Reference

#include <lsh_index.h>

Inheritance diagram for flann::LshIndex< Distance >:
Collaboration diagram for flann::LshIndex< Distance >:

Public Types

typedef Distance::ElementType ElementType
 
typedef Distance::ResultType DistanceType
 
typedef NNIndex< DistanceBaseClass
 
- Public Types inherited from flann::NNIndex< Distance >
typedef Distance::ElementType ElementType
 
typedef Distance::ResultType DistanceType
 

Public Member Functions

 LshIndex (const IndexParams &params=LshIndexParams(), Distance d=Distance())
 
 LshIndex (const Matrix< ElementType > &input_data, const IndexParams &params=LshIndexParams(), Distance d=Distance())
 
 LshIndex (const LshIndex &other)
 
LshIndexoperator= (LshIndex other)
 
virtual ~LshIndex ()
 
BaseClassclone () const
 
void addPoints (const Matrix< ElementType > &points, float rebuild_threshold=2)
 Incrementally add points to the index. More...
 
flann_algorithm_t getType () const
 
template<typename Archive >
void serialize (Archive &ar)
 
void saveIndex (FILE *stream)
 
void loadIndex (FILE *stream)
 
int usedMemory () const
 
int knnSearch (const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, size_t knn, const SearchParams &params) const
 Perform k-nearest neighbor search. More...
 
int knnSearch (const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, size_t knn, const SearchParams &params) const
 Perform k-nearest neighbor search. More...
 
void findNeighbors (ResultSet< DistanceType > &result, const ElementType *vec, const SearchParams &) const
 
virtual void buildIndex ()
 
virtual void buildIndex (const Matrix< ElementType > &dataset)
 
- Public Member Functions inherited from flann::NNIndex< Distance >
 NNIndex (Distance d)
 
 NNIndex (const IndexParams &params, Distance d)
 
 NNIndex (const NNIndex &other)
 
virtual ~NNIndex ()
 
virtual void buildIndex (const Matrix< ElementType > &dataset)
 
virtual void removePoint (size_t id)
 
virtual ElementTypegetPoint (size_t id)
 
size_t size () const
 
size_t veclen () const
 
IndexParams getParameters () const
 
template<typename Archive >
void serialize (Archive &ar)
 
int knnSearch (const Matrix< ElementType > &queries, Matrix< int > &indices, Matrix< DistanceType > &dists, size_t knn, const SearchParams &params) 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 &params) const
 Perform k-nearest neighbor search. More...
 
int knnSearch (const Matrix< ElementType > &queries, std::vector< std::vector< int > > &indices, std::vector< std::vector< DistanceType > > &dists, size_t knn, const SearchParams &params) const
 
int radiusSearch (const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams &params) const
 Perform radius search. More...
 
int radiusSearch (const Matrix< ElementType > &queries, Matrix< int > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams &params) const
 
int radiusSearch (const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, float radius, const SearchParams &params) const
 Perform radius search. More...
 
int radiusSearch (const Matrix< ElementType > &queries, std::vector< std::vector< int > > &indices, std::vector< std::vector< DistanceType > > &dists, float radius, const SearchParams &params) const
 
- Public Member Functions inherited from flann::IndexBase
virtual ~IndexBase ()
 

Protected Member Functions

void buildIndexImpl ()
 
void freeIndex ()
 
- Protected Member Functions inherited from flann::NNIndex< Distance >
size_t id_to_index (size_t id)
 
void indices_to_ids (const size_t *in, size_t *out, size_t size) const
 
void setDataset (const Matrix< ElementType > &dataset)
 
void extendDataset (const Matrix< ElementType > &new_points)
 
void cleanRemovedPoints ()
 
void swap (NNIndex &other)
 

Additional Inherited Members

- Protected Attributes inherited from flann::NNIndex< Distance >
Distance distance_
 
size_t last_id_
 
size_t size_
 
size_t size_at_build_
 
size_t veclen_
 
IndexParams index_params_
 
bool removed_
 
DynamicBitset removed_points_
 
size_t removed_count_
 
std::vector< size_t > ids_
 
std::vector< ElementType * > points_
 
ElementTypedata_ptr_
 

Detailed Description

template<typename Distance>
class flann::LshIndex< Distance >

Locality-sensitive hashing index

Contains the tables and other information for indexing a set of points for nearest-neighbor matching.

Definition at line 78 of file lsh_index.h.

Member Typedef Documentation

◆ BaseClass

template<typename Distance >
typedef NNIndex<Distance> flann::LshIndex< Distance >::BaseClass

Definition at line 84 of file lsh_index.h.

◆ DistanceType

template<typename Distance >
typedef Distance::ResultType flann::LshIndex< Distance >::DistanceType

Definition at line 82 of file lsh_index.h.

◆ ElementType

template<typename Distance >
typedef Distance::ElementType flann::LshIndex< Distance >::ElementType

Definition at line 81 of file lsh_index.h.

Constructor & Destructor Documentation

◆ LshIndex() [1/3]

template<typename Distance >
flann::LshIndex< Distance >::LshIndex ( const IndexParams params = LshIndexParams(),
Distance  d = Distance() 
)
inline

Constructor

Parameters
paramsparameters passed to the LSH algorithm
dthe distance used

Definition at line 90 of file lsh_index.h.

References flann::NNIndex< Distance >::index_params_.

Referenced by flann::LshIndex< Distance >::clone().

◆ LshIndex() [2/3]

template<typename Distance >
flann::LshIndex< Distance >::LshIndex ( const Matrix< ElementType > &  input_data,
const IndexParams params = LshIndexParams(),
Distance  d = Distance() 
)
inline

Constructor

Parameters
input_datadataset with the input features
paramsparameters passed to the LSH algorithm
dthe distance used

Definition at line 106 of file lsh_index.h.

References flann::NNIndex< Distance >::index_params_, and flann::NNIndex< Distance >::setDataset().

◆ LshIndex() [3/3]

template<typename Distance >
flann::LshIndex< Distance >::LshIndex ( const LshIndex< Distance > &  other)
inline

Definition at line 118 of file lsh_index.h.

◆ ~LshIndex()

template<typename Distance >
virtual flann::LshIndex< Distance >::~LshIndex ( )
inlinevirtual

Definition at line 133 of file lsh_index.h.

References flann::LshIndex< Distance >::freeIndex().

Member Function Documentation

◆ addPoints()

template<typename Distance >
void flann::LshIndex< Distance >::addPoints ( const Matrix< ElementType > &  points,
float  rebuild_threshold = 2 
)
inlinevirtual

◆ buildIndex() [1/2]

template<typename Distance >
virtual void flann::NNIndex< Distance >::buildIndex
inlinevirtual

Builds the index

Reimplemented from flann::NNIndex< Distance >.

Definition at line 125 of file nn_index.h.

Referenced by flann::LshIndex< Distance >::addPoints().

◆ buildIndex() [2/2]

template<typename Distance >
virtual void flann::NNIndex< Distance >::buildIndex
inlinevirtual

Builds the index using the specified dataset

Parameters
datasetthe dataset to use

Reimplemented from flann::NNIndex< Distance >.

Definition at line 141 of file nn_index.h.

◆ buildIndexImpl()

template<typename Distance >
void flann::LshIndex< Distance >::buildIndexImpl ( )
inlineprotectedvirtual

◆ clone()

template<typename Distance >
BaseClass* flann::LshIndex< Distance >::clone ( ) const
inlinevirtual

Implements flann::NNIndex< Distance >.

Definition at line 139 of file lsh_index.h.

References flann::LshIndex< Distance >::LshIndex().

◆ findNeighbors()

template<typename Distance >
void flann::LshIndex< Distance >::findNeighbors ( ResultSet< DistanceType > &  result,
const ElementType vec,
const SearchParams  
) const
inlinevirtual

Find set of nearest neighbors to vec. Their indices are stored inside the result object.

Params: result = the result object in which the indices of the nearest-neighbors are stored vec = the vector for which to search the nearest neighbors maxCheck = the maximum number of restarts (in a best-bin-first manner)

Implements flann::NNIndex< Distance >.

Definition at line 341 of file lsh_index.h.

References result.

Referenced by flann::LshIndex< Distance >::knnSearch().

◆ freeIndex()

template<typename Distance >
void flann::LshIndex< Distance >::freeIndex ( )
inlineprotectedvirtual

Implements flann::NNIndex< Distance >.

Definition at line 368 of file lsh_index.h.

Referenced by flann::LshIndex< Distance >::~LshIndex().

◆ getType()

template<typename Distance >
flann_algorithm_t flann::LshIndex< Distance >::getType ( ) const
inlinevirtual

Implements flann::IndexBase.

Definition at line 167 of file lsh_index.h.

References FLANN_INDEX_LSH.

Referenced by flann::LshIndex< Distance >::serialize().

◆ knnSearch() [1/2]

template<typename Distance >
int flann::LshIndex< Distance >::knnSearch ( const Matrix< ElementType > &  queries,
Matrix< size_t > &  indices,
Matrix< DistanceType > &  dists,
size_t  knn,
const SearchParams params 
) const
inlinevirtual

Perform k-nearest neighbor search.

Parameters
[in]queriesThe query points for which to find the nearest neighbors
[out]indicesThe indices of the nearest neighbors found
[out]distsDistances to the nearest neighbors found
[in]knnNumber of nearest neighbors to return
[in]paramsSearch parameters

Reimplemented from flann::NNIndex< Distance >.

Definition at line 224 of file lsh_index.h.

References flann::KNNResultSet< DistanceType >::clear(), flann::KNNUniqueResultSet< DistanceType >::clear(), flann::Matrix_::cols, flann::UniqueResultSet< DistanceType >::copy(), flann::KNNResultSet< DistanceType >::copy(), count, flann::LshIndex< Distance >::findNeighbors(), flann::FLANN_True, flann::NNIndex< Distance >::indices_to_ids(), min(), params, flann::Matrix_::rows, flann::KNNResultSet< DistanceType >::size(), flann::UniqueResultSet< DistanceType >::size(), and flann::NNIndex< Distance >::veclen_.

◆ knnSearch() [2/2]

template<typename Distance >
int flann::LshIndex< Distance >::knnSearch ( const Matrix< ElementType > &  queries,
std::vector< std::vector< size_t > > &  indices,
std::vector< std::vector< DistanceType > > &  dists,
size_t  knn,
const SearchParams params 
) const
inline

Perform k-nearest neighbor search.

Parameters
[in]queriesThe query points for which to find the nearest neighbors
[out]indicesThe indices of the nearest neighbors found
[out]distsDistances to the nearest neighbors found
[in]knnNumber of nearest neighbors to return
[in]paramsSearch parameters

Definition at line 279 of file lsh_index.h.

References flann::KNNResultSet< DistanceType >::clear(), flann::KNNUniqueResultSet< DistanceType >::clear(), flann::Matrix_::cols, flann::UniqueResultSet< DistanceType >::copy(), flann::KNNResultSet< DistanceType >::copy(), count, flann::LshIndex< Distance >::findNeighbors(), flann::FLANN_True, flann::NNIndex< Distance >::indices_to_ids(), min(), params, flann::Matrix_::rows, flann::KNNResultSet< DistanceType >::size(), flann::UniqueResultSet< DistanceType >::size(), and flann::NNIndex< Distance >::veclen_.

◆ loadIndex()

template<typename Distance >
void flann::LshIndex< Distance >::loadIndex ( FILE *  stream)
inlinevirtual

Implements flann::IndexBase.

Definition at line 201 of file lsh_index.h.

◆ operator=()

template<typename Distance >
LshIndex& flann::LshIndex< Distance >::operator= ( LshIndex< Distance other)
inline

Definition at line 127 of file lsh_index.h.

◆ saveIndex()

template<typename Distance >
void flann::LshIndex< Distance >::saveIndex ( FILE *  stream)
inlinevirtual

Implements flann::IndexBase.

Definition at line 195 of file lsh_index.h.

◆ serialize()

template<typename Distance >
template<typename Archive >
void flann::LshIndex< Distance >::serialize ( Archive &  ar)
inline

◆ usedMemory()

template<typename Distance >
int flann::LshIndex< Distance >::usedMemory ( ) const
inlinevirtual

Computes the index memory usage Returns: memory used by the index

Implements flann::IndexBase.

Definition at line 211 of file lsh_index.h.

References flann::NNIndex< Distance >::size_.


The documentation for this class was generated from the following file: