iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::PassThroughFilter Class Reference

#include <nrt/PointCloud2/Filter/PassThroughFilter.H>

A filter that passes through points that satisfy some criterion.

Pass through filters allow a user defined function to choose which points are allowed to be passed through the filter. In addition, the filter can either invert its output, passing through those that fail a test, or it can choose to replace values that pass some criterion instead of passing them through the filter.

A pass through filter does not allow for a call to filter() with no additional arguments. A criterion function, along with an optional value to use in replacement, are required.

Criterion functions must take in the field type under consideration and return true if the parameter passes some test, or false if it fails.

An example of such a function that passes through geometry data that falls within some range could look like:

PointCloud2 myCloud;
auto filtered = filterPointCloud( myCloud, PassThroughFilter(), [](PointCloud2::Geometry const & p){ return p.x() >= 0.0f && p.x() <= 1.0f );

The above code will filter a point cloud with a pass through filter, letting through any point with an x value in the range [0.0, 1.0].

Criterion functions can be as complicated as you wish, so long as they only operate on one point at a time

Examples:
tests/test-PointCloud2Filter.C.

Definition at line 68 of file PassThroughFilter.H.

Inheritance diagram for nrt::PassThroughFilter:
nrt::FilterBase

Public Member Functions

 PassThroughFilter (bool replaceValue=false, bool invertResult=false)
 Create a pass through filter that lets through only certain points. More...
 
PointCloud2 filter (PointCloud2 const input, std::function< bool(PointCloud2::Geometry const &)> &&func, PointCloud2::Geometry const &replaceValue=PointCloud2::Geometry())
 Filter the input, applying func to every point to see what to do. More...
 
PointCloud2 filter (PointCloud2 const input, Indices const indices, std::function< bool(PointCloud2::Geometry const &)> &&func, PointCloud2::Geometry const &replaceValue=PointCloud2::Geometry())
 Filter the input, applying func to every point in a subset to see what to do. More...
 
template<class Field >
PointCloud2 filter (PointCloud2 const input, std::function< bool(Field const &)> &&func, Field const &replaceValue=Field())
 Filter the input on a specific field, applying func to every point to see what to do. More...
 
template<class Field >
PointCloud2 filter (PointCloud2 const input, Indices const indices, std::function< bool(Field const &)> &&func, Field const &replaceValue=Field())
 Filter the input on a specific field, applying func to every point in a subset to see what to do. More...
 
template<class Field >
auto filter (PointCloud2 const input, std::function< bool(Field const &)> &&func, Field const &replaceValue) -> PointCloud2
 
template<class Field >
auto filter (PointCloud2 const input, Indices const indices, std::function< bool(Field const &)> &&func, Field const &replaceValue) -> PointCloud2
 
template<class Field >
auto filterImpl (size_t const inputSize, PointCloud2::Iterator< Field > outputEnd, std::function< bool(Field const &)> &&func, Field const &replaceValue) -> Indices
 
- Public Member Functions inherited from nrt::FilterBase
virtual ~FilterBase ()
 Virtual destruction.
 
template<class Field >
PointCloud2 filter (PointCloud2 const input)
 Force the filter to operate on a specific field, if supported. More...
 
template<class Field >
PointCloud2 filter (PointCloud2 const input, Indices const indices)
 Force the filter to operate on a specific field of a subset, if supported. More...
 

Protected Member Functions

PointCloud2 filter (PointCloud2 const input)
 Normal filtering not supported, must specify additional arguments.
 
PointCloud2 filter (PointCloud2 const input, Indices const indices)
 Normal filtering not supported, must specify additional arguments.
 
Indices filterImpl (size_t const inputSize, PointCloud2::Iterator<> outputEnd, std::function< bool(PointCloud2::Geometry const &)> &&func, PointCloud2::Geometry const &replaceValue)
 Figures out which indices we'll have to remove, if any. More...
 
template<class Field >
Indices filterImpl (size_t const inputSize, PointCloud2::Iterator< Field > outputEnd, std::function< bool(Field const &)> &&func, Field const &replaceValue)
 Figures out which indices we'll have to remove, if any, templated version. More...
 

Constructor & Destructor Documentation

nrt::PassThroughFilter::PassThroughFilter ( bool  replaceValue = false,
bool  invertResult = false 
)

Create a pass through filter that lets through only certain points.

Parameters
replaceValueWhether we will replace (true) or remove (false) points
invertResultWhether we we should invert the result of the pass through function

Member Function Documentation

PointCloud2 nrt::PassThroughFilter::filter ( PointCloud2 const  input,
std::function< bool(PointCloud2::Geometry const &)> &&  func,
PointCloud2::Geometry const &  replaceValue = PointCloud2::Geometry() 
)

Filter the input, applying func to every point to see what to do.

Parameters
inputThe cloud to filter
funcThe filtering function/functor
replaceValueThe value to use for replacement, if enabled
Returns
The filtered point cloud
PointCloud2 nrt::PassThroughFilter::filter ( PointCloud2 const  input,
Indices const  indices,
std::function< bool(PointCloud2::Geometry const &)> &&  func,
PointCloud2::Geometry const &  replaceValue = PointCloud2::Geometry() 
)

Filter the input, applying func to every point in a subset to see what to do.

Parameters
inputThe cloud to filter
indicesThe subset to operate on
funcThe filtering function/functor
replaceValueThe value to use for replacement, if enabled
Returns
The filtered point cloud
template<class Field >
PointCloud2 nrt::PassThroughFilter::filter ( PointCloud2 const  input,
std::function< bool(Field const &)> &&  func,
Field const &  replaceValue = Field() 
)

Filter the input on a specific field, applying func to every point to see what to do.

Template Parameters
FieldThe specific field to filter
Parameters
inputThe cloud to filter
funcThe filtering function/functor
replaceValueThe value to use for replacement, if enabled
Returns
The filtered point cloud
template<class Field >
PointCloud2 nrt::PassThroughFilter::filter ( PointCloud2 const  input,
Indices const  indices,
std::function< bool(Field const &)> &&  func,
Field const &  replaceValue = Field() 
)

Filter the input on a specific field, applying func to every point in a subset to see what to do.

Template Parameters
FieldThe specific field to filter
Parameters
inputThe cloud to filter
indicesThe subset to filter
funcThe filtering function/functor
replaceValueThe value to use for replacement, if enabled
Returns
The filtered point cloud
Indices nrt::PassThroughFilter::filterImpl ( size_t const  inputSize,
PointCloud2::Iterator<>  outputEnd,
std::function< bool(PointCloud2::Geometry const &)> &&  func,
PointCloud2::Geometry const &  replaceValue 
)
protected

Figures out which indices we'll have to remove, if any.

Parameters
inputSizethe size of the input
outputEndend iterator for the output
funcThe filtering function
replaceValueThe replacement value
Returns
The indices to remove
template<class Field >
Indices nrt::PassThroughFilter::filterImpl ( size_t const  inputSize,
PointCloud2::Iterator< Field >  outputEnd,
std::function< bool(Field const &)> &&  func,
Field const &  replaceValue 
)
protected

Figures out which indices we'll have to remove, if any, templated version.

Template Parameters
Thefield to filter
Parameters
inputSizethe size of the input
outputEndend iterator for the output
funcThe filtering function
replaceValueThe replacement value
Returns
The indices to remove

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