libnabo  1.0.4
Public Types | Protected Attributes | List of all members
Nabo::OpenCLSearch< T > Struct Template Reference

OpenCL support for nearest neighbour search. More...

#include <nabo_private.h>

Inheritance diagram for Nabo::OpenCLSearch< T >:
Nabo::NearestNeighbourSearch< T > Nabo::BruteForceSearchOpenCL< T > Nabo::KDTreeBalancedPtInLeavesStackOpenCL< T > Nabo::KDTreeBalancedPtInNodesStackOpenCL< T >

Public Types

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
 
- Public Types inherited from Nabo::NearestNeighbourSearch< T >
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
 

Protected Attributes

const cl_device_type deviceType
 the type of device to run CL code on (CL_DEVICE_TYPE_CPU or CL_DEVICE_TYPE_GPU)
 
cl::Context & context
 the CL context
 
cl::Kernel knnKernel
 the kernel to perform knnSearch, mutable because it is stateful, but conceptually const
 
cl::CommandQueue queue
 the command queue
 
cl::Buffer cloudCL
 the buffer for the input data
 
 OpenCLSearch (const Matrix &cloud, const Index dim, const unsigned creationOptionFlags, const cl_device_type deviceType)
 constructor, calls NearestNeighbourSearch<T>(cloud)
 
void initOpenCL (const char *clFileName, const char *kernelName, const std::string &additionalDefines="")
 Initialize CL support. More...
 
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...
 

Additional Inherited Members

- Public Member Functions inherited from Nabo::NearestNeighbourSearch< T >
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 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 =0
 Find the k nearest neighbours for each point of query. More...
 
virtual ~NearestNeighbourSearch ()
 virtual destructor
 
- Static Public Member Functions inherited from Nabo::NearestNeighbourSearch< T >
static NearestNeighbourSearchcreate (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 NearestNeighbourSearchcreateBruteForce (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 NearestNeighbourSearchcreateKDTreeLinearHeap (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 NearestNeighbourSearchcreateKDTreeTreeHeap (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...
 
- Public Attributes inherited from Nabo::NearestNeighbourSearch< T >
const Matrixcloud
 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)
 
- Protected Member Functions inherited from Nabo::NearestNeighbourSearch< T >
 NearestNeighbourSearch (const Matrix &cloud, const Index dim, const unsigned creationOptionFlags)
 constructor
 
void checkSizesKnn (const Matrix &query, const IndexMatrix &indices, const Matrix &dists2, const Index k, const unsigned optionFlags, const Vector *maxRadii=0) const
 Make sure that the output matrices have the right sizes. Throw an exception otherwise. More...
 

Detailed Description

template<typename T>
struct Nabo::OpenCLSearch< T >

OpenCL support for nearest neighbour search.

Member Function Documentation

template<typename T >
void Nabo::OpenCLSearch< T >::initOpenCL ( const char *  clFileName,
const char *  kernelName,
const std::string &  additionalDefines = "" 
)
protected

Initialize CL support.

Parameters
clFileNamename of file containing CL code
kernelNamename of the CL kernel function
additionalDefinesadditional CL code to pass to compiler
template<typename T >
unsigned long Nabo::OpenCLSearch< T >::knn ( const Matrix query,
IndexMatrix indices,
Matrix dists2,
const Index  k,
const T  epsilon,
const unsigned  optionFlags,
const T  maxRadius 
) const
virtual

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
queryquery points
indicesindices of nearest neighbours, must be of size k x query.cols()
dists2squared distances to nearest neighbours, must be of size k x query.cols()
knumber of nearest neighbour requested
epsilonmaximal 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
optionFlagssearch options, a bitwise OR of elements of SearchOptionFlags
maxRadiusmaximum 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 >.


The documentation for this struct was generated from the following files: