iLab Neuromorphic Robotics Toolkit
0.1
|
#include <nrt/PointCloud2/Search/Search.H>
A class for searching point clouds.
Provides functionality to search through a point cloud based upon an approximate KDTree implementation powered by FLANN.
Public Types | |
typedef PointCloud2::Geometry | Geometry |
typedef PointCloud2::BaseType | BaseType |
Public Member Functions | |
Search (double epsilon=0.0) | |
Create an empty search. More... | |
Search (PointCloud2 const input, double epsilon=0.0) | |
Create a new search based upon a point cloud. More... | |
Search (PointCloud2 const input, Indices const indices, double epsilon=0.0) | |
Create a new search based upon a point cloud subset. More... | |
std::vector< std::pair< size_t, BaseType > > | knn (Geometry const &query, int k) |
Perform a k-nearest neighbor search on the geometry. More... | |
template<class Field > | |
std::vector< std::pair< size_t, BaseType > > | knn (Field const &query, int k) |
Perform a k-nearest neighbor search on a specific field. More... | |
template<class Field , class Distance > | |
std::vector< std::pair< size_t, BaseType > > | knn (Field const &query, int k, Distance const &dist) |
Perform a k-nearest neighbor search on a specific field using a non-standard Distance functor. More... | |
std::vector< std::pair< size_t, BaseType > > | radius (Geometry const &query, double const radius, size_t maxResults=0, bool sort=false) |
Perform a fixed radius search on the geometry. More... | |
template<class Field > | |
std::vector< std::pair< size_t, BaseType > > | radius (Field const &query, double const radius, size_t maxResults=0, bool sort=false) |
Perform a fixed radius search on a specific field. More... | |
void | rebuild (PointCloud2 const cloud) |
Forces a rebuild on the next search to match an updated point cloud. More... | |
void | rebuild (PointCloud2 const cloud, Indices const indices) |
Forces a rebuild on the next search to match an updated point cloud. More... | |
template<class Field > | |
auto | knn (Field const &query, int k) -> std::vector< std::pair< size_t, BaseType >> |
template<class Field , class Distance > | |
auto | knn (Field const &query, int k, Distance const &dist) -> std::vector< std::pair< size_t, BaseType >> |
template<class Field , class Distance > | |
auto | knnImpl (Field const &query, int k, Distance const &dist, std::unique_ptr< flann::Index< Distance >> &indexPtr) -> std::vector< std::pair< size_t, BaseType >> |
template<class Field > | |
auto | radius (Field const &query, double const radius, size_t maxResults, bool sort) -> std::vector< std::pair< size_t, BaseType >> |
![]() | |
SourceCloud () | |
Initializes with no data. | |
SourceCloud (PointCloud2 const cloud) | |
Initializes with a point cloud and no subset. | |
SourceCloud (PointCloud2 const cloud, Indices const indices) | |
Initializes with a point cloud and a specific subset. | |
size_t | getWorkingSize () const |
Returns the current working size of the Source. More... | |
Static Public Member Functions | |
static Indices | extractIndices (std::vector< std::pair< size_t, BaseType >> const &results) |
Convenience function to extract the results of a search as a set of indices. | |
Protected Member Functions | |
template<class Field , class Distance > | |
std::vector< std::pair< size_t, BaseType > > | knnImpl (Field const &query, int k, Distance const &dist, std::unique_ptr< flann::Index< Distance >> &indexPtr) |
Does the actual work for a specific field knn search. More... | |
bool | rebuildFLANNIndex () |
Rebuilds FLANN index if necessary. More... | |
template<class Field > | |
bool | rebuildFLANNIndex () |
Rebuilds FLANN index if necessary. More... | |
template<class Field , class Distance > | |
bool | rebuildFLANNIndex (Distance const &dist, std::unique_ptr< flann::Index< Distance >> &indexPtr) |
Rebuilds FLANN index if necessary. More... | |
![]() | |
void | setCloud (PointCloud2 const cloud) |
Sets to use a specific cloud. | |
void | setCloud (PointCloud2 const cloud, Indices const indices) |
Sets to sue a specific subset of a cloud. | |
Additional Inherited Members | |
![]() | |
PointCloud2 | cloud |
The source point cloud. | |
Indices | indices |
The optional indices. | |
bool | useSubset |
Whether we use a subset or not. | |
nrt::Search::Search | ( | double | epsilon = 0.0 ) |
Create an empty search.
For this search to work, you will need to explicitly call rebuild before performing a search.
epsilon | The minimum required accuracy of the search |
nrt::Search::Search | ( | PointCloud2 const | input, |
double | epsilon = 0.0 |
||
) |
Create a new search based upon a point cloud.
The cloud will be indexed as soon as the first search is conducted. If the search type changes, the index will be rebuilt to the latest search field type
input | The point cloud to search |
epsilon | The minimum required accuracy of the search |
nrt::Search::Search | ( | PointCloud2 const | input, |
Indices const | indices, | ||
double | epsilon = 0.0 |
||
) |
Create a new search based upon a point cloud subset.
The cloud will be indexed as soon as the first search is conducted. If the search type changes, the index will be rebuilt to the latest search field type
input | The point cloud to search |
indices | The subset of the cloud to search through |
epsilon | The minimum required accuracy of the search |
std::vector<std::pair<size_t, BaseType> > nrt::Search::knn | ( | Geometry const & | query, |
int | k | ||
) |
Perform a k-nearest neighbor search on the geometry.
Will rebuild the search index if the previous search type was not geometry.
If this search is operating upon a subset, the returned indices will refer to the original cloud and not the subset (e.g. instead of 0 referring to the first subset index, it will refer to the real index of whatever subset[0] represents).
query | The geometrical query |
k | The maximum number of neighbors to find |
Referenced by nrt::CorrespondenceEstimationNearestNeighbor::findReciprocalCorrespondence().
std::vector<std::pair<size_t, BaseType> > nrt::Search::knn | ( | Field const & | query, |
int | k | ||
) |
Perform a k-nearest neighbor search on a specific field.
Will rebuild the search index if the previous search type was not Field.
If this search is operating upon a subset, the returned indices will refer to the original cloud and not the subset (e.g. instead of 0 referring to the first subset index, it will refer to the real index of whatever subset[0] represents).
query | The specific field query |
k | The maximum number of neighbors to find |
std::vector<std::pair<size_t, BaseType> > nrt::Search::knn | ( | Field const & | query, |
int | k, | ||
Distance const & | dist | ||
) |
Perform a k-nearest neighbor search on a specific field using a non-standard Distance functor.
Will rebuild the search index if the previous search type was not Field or the distance functor changed.
If this search is operating upon a subset, the returned indices will refer to the original cloud and not the subset (e.g. instead of 0 referring to the first subset index, it will refer to the real index of whatever subset[0] represents).
Field | The field to query. Can be the geometry as well. |
Distance | The distance functor type |
query | The specific field query |
k | The maximum number of neighbors to find |
dist | The distance functor (see flann documentation for examples) |
std::vector<std::pair<size_t, BaseType> > nrt::Search::radius | ( | Geometry const & | query, |
double const | radius, | ||
size_t | maxResults = 0 , |
||
bool | sort = false |
||
) |
Perform a fixed radius search on the geometry.
Will rebuild the search index if the previous search type was not geometry.
If this search is operating upon a subset, the returned indices will refer to the original cloud and not the subset (e.g. instead of 0 referring to the first subset index, it will refer to the real index of whatever subset[0] represents).
query | The geometrical query |
radius | The radius within query to find neighbors |
maxResults | The maximum number of neighbors to find. Zero or > cloud size to return maximum. |
sort | Whether to sort results by distance (will slow down computation) |
std::vector<std::pair<size_t, BaseType> > nrt::Search::radius | ( | Field const & | query, |
double const | radius, | ||
size_t | maxResults = 0 , |
||
bool | sort = false |
||
) |
Perform a fixed radius search on a specific field.
Will rebuild the search index if the previous search type was not Field.
If this search is operating upon a subset, the returned indices will refer to the original cloud and not the subset (e.g. instead of 0 referring to the first subset index, it will refer to the real index of whatever subset[0] represents).
query | The specific field query |
radius | The radius within query to find neighbors |
maxResults | The maximum number of neighbors to find. Zero or > cloud size to return maximum. |
sort | Whether to sort results by distance (will slow down computation) |
void nrt::Search::rebuild | ( | PointCloud2 const | cloud) |
Forces a rebuild on the next search to match an updated point cloud.
Since the cloud we reference may be changed externally, which would cause the external cloud to create its own copy of the data, it may be necessary to update the cloud that search is referencing
void nrt::Search::rebuild | ( | PointCloud2 const | cloud, |
Indices const | indices | ||
) |
Forces a rebuild on the next search to match an updated point cloud.
Since the cloud we reference may be changed externally, which would cause the external cloud to create its own copy of the data, it may be necessary to update the cloud that search is referencing
|
protected |
Does the actual work for a specific field knn search.
Will rebuild the search index if the previous search type was not Field or the distance functor changed.
If this search is operating upon a subset, the returned indices will refer to the original cloud and not the subset (e.g. instead of 0 referring to the first subset index, it will refer to the real index of whatever subset[0] represents).
Field | The field to query. Can be the geometry as well. |
Distance | The distance functor type |
query | The specific field query |
k | The maximum number of neighbors to find |
dist | The distance functor (see flann documentation for examples) |
indexPtr | a unique_ptr that is the sole owner of the FLANN index to use |
|
inlineprotected |
Rebuilds FLANN index if necessary.
Definition at line 176 of file SearchImpl.H.
|
protected |
Rebuilds FLANN index if necessary.
|
inlineprotected |
Rebuilds FLANN index if necessary.
Definition at line 182 of file SearchImpl.H.
References nrt::SourceCloud::cloud, nrt::SourceCloud::indices, and nrt::SourceCloud::useSubset.