KDTree, unbalanced, points in leaves, stack, implicit bounds, ANN_KD_SL_MIDPT, optimised implementation.
More...
#include <nabo_private.h>
|
typedef NearestNeighbourSearch< T >::Vector | Vector |
|
typedef NearestNeighbourSearch< T >::Matrix | Matrix |
|
typedef NearestNeighbourSearch< T >::Index | Index |
|
typedef NearestNeighbourSearch< T >::IndexVector | IndexVector |
|
typedef NearestNeighbourSearch< T >::IndexMatrix | IndexMatrix |
|
enum | SearchType {
BRUTE_FORCE = 0,
KDTREE_LINEAR_HEAP,
KDTREE_TREE_HEAP,
KDTREE_CL_PT_IN_NODES,
KDTREE_CL_PT_IN_LEAVES,
BRUTE_FORCE_CL,
SEARCH_TYPE_COUNT
} |
| type of search More...
|
|
enum | CreationOptionFlags { TOUCH_STATISTICS = 1
} |
| creation option More...
|
|
enum | SearchOptionFlags { ALLOW_SELF_MATCH = 1,
SORT_RESULTS = 2
} |
| search option More...
|
|
typedef Eigen::Matrix< T, Eigen::Dynamic, 1 > | Vector |
| an Eigen vector of type T, to hold the coordinates of a point
|
|
typedef Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > | Matrix |
| a column-major Eigen matrix in which each column is a point; this matrix has dim rows
|
|
typedef int | Index |
| an index to a Vector or a Matrix, for refering to data points
|
|
typedef Eigen::Matrix< Index, Eigen::Dynamic, 1 > | IndexVector |
| a vector of indices to data points
|
|
typedef Eigen::Matrix< Index, Eigen::Dynamic, Eigen::Dynamic > | IndexMatrix |
| a matrix of indices to data points
|
|
|
typedef std::vector< Index > | BuildPoints |
| indices of points during kd-tree construction
|
|
typedef BuildPoints::iterator | BuildPointsIt |
| iterator to indices of points during kd-tree construction
|
|
typedef BuildPoints::const_iterator | BuildPointsCstIt |
| const-iterator to indices of points during kd-tree construction
|
|
typedef std::vector< Node > | Nodes |
| dense vector of search nodes, provides better memory performances than many small objects
|
|
typedef std::vector< BucketEntry > | Buckets |
| bucket data
|
|
|
const unsigned | bucketSize |
| size of bucket
|
|
const uint32_t | dimBitCount |
| number of bits required to store dimension index + number of dimensions
|
|
const uint32_t | dimMask |
| mask to access dim
|
|
Nodes | nodes |
| search nodes
|
|
Buckets | buckets |
| buckets
|
|
std::pair< T, T > | getBounds (const BuildPointsIt first, const BuildPointsIt last, const unsigned dim) |
| return the bounds of points from [first..last[ on dimension dim
|
|
unsigned | buildNodes (const BuildPointsIt first, const BuildPointsIt last, const Vector minValues, const Vector maxValues) |
| construct nodes for points [first..last[ inside the hyperrectangle [minValues..maxValues]
|
|
unsigned long | onePointKnn (const Matrix &query, IndexMatrix &indices, Matrix &dists2, int i, Heap &heap, std::vector< T > &off, const T maxError, const T maxRadius2, const bool allowSelfMatch, const bool collectStatistics, const bool sortResults) const |
| search one point, call recurseKnn with the correct template parameters More...
|
|
template<bool allowSelfMatch, bool collectStatistics> |
unsigned long | recurseKnn (const T *query, const unsigned n, T rd, Heap &heap, std::vector< T > &off, const T maxError, const T maxRadius2) const |
| recursive search, strongly inspired by ANN and [Arya & Mount, Algorithms for fast vector quantization, 1993] More...
|
|
| KDTreeUnbalancedPtInLeavesImplicitBoundsStackOpt (const Matrix &cloud, const Index dim, const unsigned creationOptionFlags, const Parameters &additionalParameters) |
| constructor, calls NearestNeighbourSearch<T>(cloud)
|
|
virtual unsigned long | knn (const Matrix &query, IndexMatrix &indices, Matrix &dists2, const Index k, const T epsilon, const unsigned optionFlags, const T maxRadius) const |
| Find the k nearest neighbours for each point of query. More...
|
|
virtual unsigned long | knn (const Matrix &query, IndexMatrix &indices, Matrix &dists2, const Vector &maxRadii, const Index k=1, const T epsilon=0, const unsigned optionFlags=0) const |
| Find the k nearest neighbours for each point of query. More...
|
|
|
unsigned long | knn (const Vector &query, IndexVector &indices, Vector &dists2, const Index k=1, const T epsilon=0, const unsigned optionFlags=0, const T maxRadius=std::numeric_limits< T >::infinity()) const |
| Find the k nearest neighbours of query. More...
|
|
virtual | ~NearestNeighbourSearch () |
| virtual destructor
|
|
static NearestNeighbourSearch * | create (const Matrix &cloud, const Index dim=std::numeric_limits< Index >::max(), const SearchType preferedType=KDTREE_LINEAR_HEAP, const unsigned creationOptionFlags=0, const Parameters &additionalParameters=Parameters()) |
| Create a nearest-neighbour search. More...
|
|
static NearestNeighbourSearch * | createBruteForce (const Matrix &cloud, const Index dim=std::numeric_limits< Index >::max(), const unsigned creationOptionFlags=0) |
| Create a nearest-neighbour search, using brute-force search, useful for comparison only. More...
|
|
static NearestNeighbourSearch * | createKDTreeLinearHeap (const Matrix &cloud, const Index dim=std::numeric_limits< Index >::max(), const unsigned creationOptionFlags=0, const Parameters &additionalParameters=Parameters()) |
| Create a nearest-neighbour search, using a kd-tree with linear heap, good for small k (~up to 30) More...
|
|
static NearestNeighbourSearch * | createKDTreeTreeHeap (const Matrix &cloud, const Index dim=std::numeric_limits< Index >::max(), const unsigned creationOptionFlags=0, const Parameters &additionalParameters=Parameters()) |
| Create a nearest-neighbour search, using a kd-tree with tree heap, good for large k (~from 30) More...
|
|
const Matrix & | cloud |
| the reference to the data-point cloud, which must remain valid during the lifetime of the NearestNeighbourSearch object
|
|
const Index | dim |
| the dimensionality of the data-point cloud
|
|
const unsigned | creationOptionFlags |
| creation options
|
|
const Vector | minBound |
| the low bound of the search space (axis-aligned bounding box)
|
|
const Vector | maxBound |
| the high bound of the search space (axis-aligned bounding box)
|
|
template<typename T, typename Heap>
struct Nabo::KDTreeUnbalancedPtInLeavesImplicitBoundsStackOpt< T, Heap >
KDTree, unbalanced, points in leaves, stack, implicit bounds, ANN_KD_SL_MIDPT, optimised implementation.
◆ knn() [1/2]
template<typename T , typename Heap >
Find the k nearest neighbours for each point of query.
If the search finds less than k points, the empty entries in dists2 will be filled with infinity and the indices with 0.
- Parameters
-
query | query points |
indices | indices of nearest neighbours, must be of size k x query.cols() |
dists2 | squared distances to nearest neighbours, must be of size k x query.cols() |
k | number of nearest neighbour requested |
epsilon | maximal ratio of error for approximate search, 0 for exact search; has no effect if the number of neighbour found is smaller than the number requested |
optionFlags | search options, a bitwise OR of elements of SearchOptionFlags |
maxRadius | maximum radius in which to search, can be used to prune search, is not affected by epsilon |
- Returns
- if creationOptionFlags contains TOUCH_STATISTICS, return the number of point touched, otherwise return 0
Implements Nabo::NearestNeighbourSearch< T >.
◆ knn() [2/2]
template<typename T , typename Heap >
Find the k nearest neighbours for each point of query.
If the search finds less than k points, the empty entries in dists2 will be filled with infinity and the indices with 0.
- Parameters
-
query | query points |
indices | indices of nearest neighbours, must be of size k x query.cols() |
dists2 | squared distances to nearest neighbours, must be of size k x query.cols() |
maxRadii | vector of maximum radii in which to search, used to prune search, is not affected by epsilon |
k | number of nearest neighbour requested |
epsilon | maximal ratio of error for approximate search, 0 for exact search; has no effect if the number of neighbour found is smaller than the number requested |
optionFlags | search options, a bitwise OR of elements of SearchOptionFlags |
- Returns
- if creationOptionFlags contains TOUCH_STATISTICS, return the number of point touched, otherwise return 0
Implements Nabo::NearestNeighbourSearch< T >.
◆ onePointKnn()
template<typename T , typename Heap >
unsigned long Nabo::KDTreeUnbalancedPtInLeavesImplicitBoundsStackOpt< T, Heap >::onePointKnn |
( |
const Matrix & |
query, |
|
|
IndexMatrix & |
indices, |
|
|
Matrix & |
dists2, |
|
|
int |
i, |
|
|
Heap & |
heap, |
|
|
std::vector< T > & |
off, |
|
|
const T |
maxError, |
|
|
const T |
maxRadius2, |
|
|
const bool |
allowSelfMatch, |
|
|
const bool |
collectStatistics, |
|
|
const bool |
sortResults |
|
) |
| const |
|
protected |
search one point, call recurseKnn with the correct template parameters
- Parameters
-
query | pointer to query coordinates |
indices | indices of nearest neighbours, must be of size k x query.cols() |
dists2 | squared distances to nearest neighbours, must be of size k x query.cols() |
i | index of point to search |
heap | reference to heap |
off | reference to array of offsets |
maxError | error factor (1 + epsilon) |
maxRadius2 | square of maximum radius |
allowSelfMatch | whether to allow self match |
collectStatistics | whether to collect statistics |
sortResults | wether to sort results |
◆ recurseKnn()
template<typename T , typename Heap >
template<bool allowSelfMatch, bool collectStatistics>
recursive search, strongly inspired by ANN and [Arya & Mount, Algorithms for fast vector quantization, 1993]
- Parameters
-
query | pointer to query coordinates |
n | index of node to visit |
rd | squared dist to this rect |
heap | reference to heap |
off | reference to array of offsets |
maxError | error factor (1 + epsilon) |
maxRadius2 | square of maximum radius |
The documentation for this struct was generated from the following files: