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

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

A filter that downsamples an input point cloud into a uniform grid.

Voxel filters allow large point clouds to be down sampled into smaller more tractable datasets by applying some downsampling function to a group of points that all fall within some geometrical location.

The size of the geometry used to cluster points is specified on filter creation.

Voxel filters rely on user specified down sampling functions or can be performed using a default downsampling method which makes no guarantees to the validity of any field other than Geometry in the output cloud.

See GeometryAverage and GeometryColorAverage for examples on how to specify a downsampling function.

Examples:
tests/test-PointCloud2OpenNI.C.

Definition at line 63 of file VoxelFilter.H.

Inheritance diagram for nrt::VoxelFilter:
nrt::FilterBase

Classes

struct  Voxel
 A struct representing a voxel object. More...
 

Public Types

typedef std::function< void(PointCloud2
const, PointCloud2 &, Voxel
const &)> 
DownSamplingFunc
 The function type for downsampling voxels. More...
 

Public Member Functions

 VoxelFilter (Geometry const &gridSize)
 Create a voxel filter with a specific voxel grid size.
 
PointCloud2 filter (PointCloud2 const input)
 Performs default filtering (geometry only, no guarantee on validity of other fields) More...
 
PointCloud2 filter (PointCloud2 const input, DownSamplingFunc &&func)
 Filter the input, applying func to every point to see what to do. More...
 
int getVoxelIndex (Geometry const &point) const
 Gets the index of the voxel corresponding to an input point. More...
 
std::map< int, int > getVoxelIndexMap () const
 Gets the mapping from voxel coordinates to output cloud 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...
 

Static Public Member Functions

static DownSamplingFunc GeometryAverage ()
 A sample geometry only downsampling function. More...
 
static DownSamplingFunc GeometryColorAverage ()
 A sample geometry and color downsampling function. More...
 

Protected Member Functions

PointCloud2 filter (PointCloud2 const input, Indices const indices)
 Not yet implemented TODO.
 

Member Typedef Documentation

typedef std::function<void(PointCloud2 const, PointCloud2 &, Voxel const &)> nrt::VoxelFilter::DownSamplingFunc

The function type for downsampling voxels.

A downsampling function must accept a constant version of the input point cloud, a reference to the output point cloud, and a constant reference to a voxel describing the relationship between points in the input to points in the output cloud.

Definition at line 87 of file VoxelFilter.H.

Member Function Documentation

static DownSamplingFunc nrt::VoxelFilter::GeometryAverage ( )
static

A sample geometry only downsampling function.

This downsampling function does nothing to ensure that the output has valid entries in any field except its geometry; if the cloud had other dense or sparse fields prior to this, their values are not guaranteed to be valid and should be assumed to be all invalid

static DownSamplingFunc nrt::VoxelFilter::GeometryColorAverage ( )
static

A sample geometry and color downsampling function.

This downsampling function does nothing to ensure that the output has valid entries in any field except its geometry and color information; if the cloud had other dense or sparse fields prior to this, their values are not guaranteed to be valid and should be assumed to be all invalid

Examples:
tests/test-PointCloud2OpenNI.C.
PointCloud2 nrt::VoxelFilter::filter ( PointCloud2 const  input)
virtual

Performs default filtering (geometry only, no guarantee on validity of other fields)

Parameters
inputThe cloud to filter
Returns
The filtered cloud

Implements nrt::FilterBase.

PointCloud2 nrt::VoxelFilter::filter ( PointCloud2 const  input,
DownSamplingFunc &&  func 
)

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

Parameters
inputThe cloud to filter
funcThe filtering function/functor
Returns
The filtered point cloud
int nrt::VoxelFilter::getVoxelIndex ( Geometry const &  point) const

Gets the index of the voxel corresponding to an input point.

The input point should be one that was in the original point cloud used to create the voxel grid, otherwise the result is not guaranteed to be valid.

This result is only valid for the most recently filtered point cloud.

Returns
the index of the point, or -1 if invalid

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