Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rtflann::NNIndex< Distance > Class Template Referenceabstract

#include <nn_index.h>

Inheritance diagram for rtflann::NNIndex< Distance >:
Inheritance graph
[legend]

Public Types

typedef Distance::ResultType DistanceType
 
typedef Distance::ElementType ElementType
 

Public Member Functions

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

Protected Member Functions

virtual void buildIndexImpl ()=0
 
void cleanRemovedPoints ()
 
void extendDataset (const Matrix< ElementType > &new_points)
 
virtual void freeIndex ()=0
 
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 swap (NNIndex &other)
 

Protected Attributes

ElementTypedata_ptr_
 
Distance distance_
 
std::vector< size_tids_
 
IndexParams index_params_
 
size_t last_id_
 
std::vector< ElementType * > points_
 
bool removed_
 
size_t removed_count_
 
DynamicBitset removed_points_
 
size_t size_
 
size_t size_at_build_
 
size_t veclen_
 

Detailed Description

template<typename Distance>
class rtflann::NNIndex< Distance >

Nearest-neighbour index base class

Definition at line 101 of file nn_index.h.

Member Typedef Documentation

◆ DistanceType

template<typename Distance >
typedef Distance::ResultType rtflann::NNIndex< Distance >::DistanceType

Definition at line 105 of file nn_index.h.

◆ ElementType

template<typename Distance >
typedef Distance::ElementType rtflann::NNIndex< Distance >::ElementType

Definition at line 104 of file nn_index.h.

Constructor & Destructor Documentation

◆ NNIndex() [1/3]

template<typename Distance >
rtflann::NNIndex< Distance >::NNIndex ( Distance  d)
inline

Definition at line 107 of file nn_index.h.

◆ NNIndex() [2/3]

template<typename Distance >
rtflann::NNIndex< Distance >::NNIndex ( const IndexParams params,
Distance  d 
)
inline

Definition at line 112 of file nn_index.h.

◆ NNIndex() [3/3]

template<typename Distance >
rtflann::NNIndex< Distance >::NNIndex ( const NNIndex< Distance > &  other)
inline

Definition at line 117 of file nn_index.h.

◆ ~NNIndex()

template<typename Distance >
virtual rtflann::NNIndex< Distance >::~NNIndex ( )
inlinevirtual

Definition at line 140 of file nn_index.h.

Member Function Documentation

◆ addPoints()

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

◆ buildIndex() [1/2]

template<typename Distance >
virtual void rtflann::NNIndex< Distance >::buildIndex ( )
inlinevirtual

Builds the index

Reimplemented in rtflann::CompositeIndex< Distance >, and rtflann::AutotunedIndex< Distance >.

Definition at line 153 of file nn_index.h.

◆ buildIndex() [2/2]

template<typename Distance >
virtual void rtflann::NNIndex< Distance >::buildIndex ( const Matrix< ElementType > &  dataset)
inlinevirtual

Builds the index using the specified dataset

Parameters
datasetthe dataset to use

Reimplemented in rtflann::AutotunedIndex< Distance >.

Definition at line 169 of file nn_index.h.

◆ buildIndexImpl()

template<typename Distance >
virtual void rtflann::NNIndex< Distance >::buildIndexImpl ( )
protectedpure virtual

◆ cleanRemovedPoints()

template<typename Distance >
void rtflann::NNIndex< Distance >::cleanRemovedPoints ( )
inlineprotected

Definition at line 820 of file nn_index.h.

◆ clone()

template<typename Distance >
virtual NNIndex* rtflann::NNIndex< Distance >::clone ( ) const
pure virtual

◆ extendDataset()

template<typename Distance >
void rtflann::NNIndex< Distance >::extendDataset ( const Matrix< ElementType > &  new_points)
inlineprotected

Definition at line 801 of file nn_index.h.

◆ findNeighbors()

template<typename Distance >
virtual void rtflann::NNIndex< Distance >::findNeighbors ( ResultSet< DistanceType > &  result,
const ElementType vec,
const SearchParams searchParams 
) const
pure virtual

◆ freeIndex()

template<typename Distance >
virtual void rtflann::NNIndex< Distance >::freeIndex ( )
protectedpure virtual

◆ getParameters()

template<typename Distance >
IndexParams rtflann::NNIndex< Distance >::getParameters ( ) const
inlinevirtual

Returns the parameters used by the index.

Returns
The index parameters

Implements rtflann::IndexBase.

Definition at line 257 of file nn_index.h.

◆ getPoint()

template<typename Distance >
virtual ElementType* rtflann::NNIndex< Distance >::getPoint ( size_t  id)
inlinevirtual

Get point with specific id

Parameters
id
Returns

Definition at line 215 of file nn_index.h.

◆ id_to_index()

template<typename Distance >
size_t rtflann::NNIndex< Distance >::id_to_index ( size_t  id)
inlineprotected

Definition at line 743 of file nn_index.h.

◆ indices_to_ids()

template<typename Distance >
void rtflann::NNIndex< Distance >::indices_to_ids ( const size_t in,
size_t out,
size_t  size 
) const
inlineprotected

Definition at line 775 of file nn_index.h.

◆ knnSearch() [1/3]

template<typename Distance >
virtual int rtflann::NNIndex< 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 in rtflann::AutotunedIndex< Distance >, and rtflann::LshIndex< Distance >.

Definition at line 343 of file nn_index.h.

◆ knnSearch() [2/3]

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

Definition at line 504 of file nn_index.h.

◆ knnSearch() [3/3]

template<typename Distance >
virtual int rtflann::NNIndex< 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
inlinevirtual

Perform k-nearest neighbor search.

Parameters
queries
indices
dists
knn
params
Returns
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 in rtflann::LshIndex< Distance >, and rtflann::AutotunedIndex< Distance >.

Definition at line 433 of file nn_index.h.

◆ radiusSearch() [1/4]

template<typename Distance >
int rtflann::NNIndex< Distance >::radiusSearch ( const Matrix< ElementType > &  queries,
Matrix< int > &  indices,
Matrix< DistanceType > &  dists,
float  radius,
const SearchParams params 
) const
inline
Parameters
queries
indices
dists
radius
params
Returns

Definition at line 612 of file nn_index.h.

◆ radiusSearch() [2/4]

template<typename Distance >
virtual int rtflann::NNIndex< Distance >::radiusSearch ( const Matrix< ElementType > &  queries,
Matrix< size_t > &  indices,
Matrix< DistanceType > &  dists,
float  radius,
const SearchParams params 
) const
inlinevirtual

Perform radius search.

Parameters
[in]queryThe query point
[out]indicesThe indices of the neighbors found within the given radius
[out]distsThe distances to the nearest neighbors found
[in]radiusThe radius used for search
[in]paramsSearch parameters
Returns
Number of neighbors found

Definition at line 529 of file nn_index.h.

◆ radiusSearch() [3/4]

template<typename Distance >
int rtflann::NNIndex< Distance >::radiusSearch ( const Matrix< ElementType > &  queries,
std::vector< std::vector< int > > &  indices,
std::vector< std::vector< DistanceType > > &  dists,
float  radius,
const SearchParams params 
) const
inline
Parameters
queries
indices
dists
radius
params
Returns

Definition at line 718 of file nn_index.h.

◆ radiusSearch() [4/4]

template<typename Distance >
virtual int rtflann::NNIndex< Distance >::radiusSearch ( const Matrix< ElementType > &  queries,
std::vector< std::vector< size_t > > &  indices,
std::vector< std::vector< DistanceType > > &  dists,
float  radius,
const SearchParams params 
) const
inlinevirtual

Perform radius search.

Parameters
[in]queryThe query point
[out]indicesThe indices of the neighbors found within the given radius
[out]distsThe distances to the nearest neighbors found
[in]radiusThe radius used for search
[in]paramsSearch parameters
Returns
Number of neighbors found

Definition at line 639 of file nn_index.h.

◆ removedCount()

template<typename Distance >
size_t rtflann::NNIndex< Distance >::removedCount ( ) const
inline

Definition at line 234 of file nn_index.h.

◆ removePoint()

template<typename Distance >
virtual void rtflann::NNIndex< Distance >::removePoint ( size_t  id)
inlinevirtual

Remove point from the index

Parameters
indexIndex of point to be removed

Reimplemented in rtflann::CompositeIndex< Distance >, and rtflann::AutotunedIndex< Distance >.

Definition at line 189 of file nn_index.h.

◆ serialize()

template<typename Distance >
template<typename Archive >
void rtflann::NNIndex< Distance >::serialize ( Archive &  ar)
inline

Definition at line 264 of file nn_index.h.

◆ setDataset()

template<typename Distance >
void rtflann::NNIndex< Distance >::setDataset ( const Matrix< ElementType > &  dataset)
inlineprotected

Definition at line 784 of file nn_index.h.

◆ size()

template<typename Distance >
size_t rtflann::NNIndex< Distance >::size ( ) const
inlinevirtual
Returns
number of features in this index.

Implements rtflann::IndexBase.

Definition at line 229 of file nn_index.h.

◆ sizeAtBuild()

template<typename Distance >
size_t rtflann::NNIndex< Distance >::sizeAtBuild ( ) const
inline

Definition at line 239 of file nn_index.h.

◆ swap()

template<typename Distance >
void rtflann::NNIndex< Distance >::swap ( NNIndex< Distance > &  other)
inlineprotected

Definition at line 840 of file nn_index.h.

◆ veclen()

template<typename Distance >
size_t rtflann::NNIndex< Distance >::veclen ( ) const
inlinevirtual
Returns
The dimensionality of the features in this index.

Implements rtflann::IndexBase.

Definition at line 247 of file nn_index.h.

Member Data Documentation

◆ data_ptr_

template<typename Distance >
ElementType* rtflann::NNIndex< Distance >::data_ptr_
protected

Pointer to dataset memory if allocated by this index, otherwise NULL

Definition at line 919 of file nn_index.h.

◆ distance_

template<typename Distance >
Distance rtflann::NNIndex< Distance >::distance_
protected

The distance functor

Definition at line 861 of file nn_index.h.

◆ ids_

template<typename Distance >
std::vector<size_t> rtflann::NNIndex< Distance >::ids_
protected

Array of point IDs, returned by nearest-neighbour operations

Definition at line 909 of file nn_index.h.

◆ index_params_

template<typename Distance >
IndexParams rtflann::NNIndex< Distance >::index_params_
protected

Parameters of the index.

Definition at line 889 of file nn_index.h.

◆ last_id_

template<typename Distance >
size_t rtflann::NNIndex< Distance >::last_id_
protected

Each index point has an associated ID. IDs are assigned sequentially in increasing order. This indicates the ID assigned to the last point added to the index.

Definition at line 869 of file nn_index.h.

◆ points_

template<typename Distance >
std::vector<ElementType*> rtflann::NNIndex< Distance >::points_
protected

Point data

Definition at line 914 of file nn_index.h.

◆ removed_

template<typename Distance >
bool rtflann::NNIndex< Distance >::removed_
protected

Flag indicating if at least a point was removed from the index

Definition at line 894 of file nn_index.h.

◆ removed_count_

template<typename Distance >
size_t rtflann::NNIndex< Distance >::removed_count_
protected

Number of points removed from the index

Definition at line 904 of file nn_index.h.

◆ removed_points_

template<typename Distance >
DynamicBitset rtflann::NNIndex< Distance >::removed_points_
protected

Array used to mark points removed from the index

Definition at line 899 of file nn_index.h.

◆ size_

template<typename Distance >
size_t rtflann::NNIndex< Distance >::size_
protected

Number of points in the index (and database)

Definition at line 874 of file nn_index.h.

◆ size_at_build_

template<typename Distance >
size_t rtflann::NNIndex< Distance >::size_at_build_
protected

Number of features in the dataset when the index was last built.

Definition at line 879 of file nn_index.h.

◆ veclen_

template<typename Distance >
size_t rtflann::NNIndex< Distance >::veclen_
protected

Size of one point in the index (and database)

Definition at line 884 of file nn_index.h.


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


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:29