voxel_grid.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#pragma once
#include <pcl/filters/boost.h>
#include <pcl/filters/filter.h>
#include <map>
namespace pcl
{
/** \brief Obtain the maximum and minimum points in 3D from a given point cloud.
* \param[in] cloud the pointer to a pcl::PCLPointCloud2 dataset
* \param[in] x_idx the index of the X channel
* \param[in] y_idx the index of the Y channel
* \param[in] z_idx the index of the Z channel
* \param[out] min_pt the minimum data point
* \param[out] max_pt the maximum data point
*/
PCL_EXPORTS void
getMinMax3D (const pcl::PCLPointCloud2ConstPtr &cloud, int x_idx, int y_idx, int z_idx,
Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt);
/** \brief Obtain the maximum and minimum points in 3D from a given point cloud.
* \note Performs internal data filtering as well.
* \param[in] cloud the pointer to a pcl::PCLPointCloud2 dataset
* \param[in] x_idx the index of the X channel
* \param[in] y_idx the index of the Y channel
* \param[in] z_idx the index of the Z channel
* \param[in] distance_field_name the name of the dimension to filter data along to
* \param[in] min_distance the minimum acceptable value in \a distance_field_name data
* \param[in] max_distance the maximum acceptable value in \a distance_field_name data
* \param[out] min_pt the minimum data point
* \param[out] max_pt the maximum data point
* \param[in] limit_negative \b false if data \b inside of the [min_distance; max_distance] interval should be
* considered, \b true otherwise.
*/
PCL_EXPORTS void
getMinMax3D (const pcl::PCLPointCloud2ConstPtr &cloud, int x_idx, int y_idx, int z_idx,
const std::string &distance_field_name, float min_distance, float max_distance,
Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt, bool limit_negative = false);
/** \brief Get the relative cell indices of the "upper half" 13 neighbors.
* \note Useful in combination with getNeighborCentroidIndices() from \ref VoxelGrid
* \ingroup filters
*/
inline Eigen::MatrixXi
getHalfNeighborCellIndices ()
{
Eigen::MatrixXi relative_coordinates (3, 13);
int idx = 0;
// 0 - 8
for (int i = -1; i < 2; i++)
{
for (int j = -1; j < 2; j++)
{
relative_coordinates (0, idx) = i;
relative_coordinates (1, idx) = j;
relative_coordinates (2, idx) = -1;
idx++;
}
}
// 9 - 11
for (int i = -1; i < 2; i++)
{
relative_coordinates (0, idx) = i;
relative_coordinates (1, idx) = -1;
relative_coordinates (2, idx) = 0;
idx++;
}
// 12
relative_coordinates (0, idx) = -1;
relative_coordinates (1, idx) = 0;
relative_coordinates (2, idx) = 0;
return (relative_coordinates);
}
/** \brief Get the relative cell indices of all the 26 neighbors.
* \note Useful in combination with getNeighborCentroidIndices() from \ref VoxelGrid
* \ingroup filters
*/
inline Eigen::MatrixXi
getAllNeighborCellIndices ()
{
Eigen::MatrixXi relative_coordinates = getHalfNeighborCellIndices ();
Eigen::MatrixXi relative_coordinates_all( 3, 26);
relative_coordinates_all.block<3, 13> (0, 0) = relative_coordinates;
relative_coordinates_all.block<3, 13> (0, 13) = -relative_coordinates;
return (relative_coordinates_all);
}
/** \brief Get the minimum and maximum values on each of the 3 (x-y-z) dimensions
* in a given pointcloud, without considering points outside of a distance threshold from the laser origin
* \param[in] cloud the point cloud data message
* \param[in] distance_field_name the field name that contains the distance values
* \param[in] min_distance the minimum distance a point will be considered from
* \param[in] max_distance the maximum distance a point will be considered to
* \param[out] min_pt the resultant minimum bounds
* \param[out] max_pt the resultant maximum bounds
* \param[in] limit_negative if set to true, then all points outside of the interval (min_distance;max_distace) are considered
* \ingroup filters
*/
template <typename PointT> void
getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
const std::string &distance_field_name, float min_distance, float max_distance,
Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt, bool limit_negative = false);
/** \brief Get the minimum and maximum values on each of the 3 (x-y-z) dimensions
* in a given pointcloud, without considering points outside of a distance threshold from the laser origin
* \param[in] cloud the point cloud data message
* \param[in] indices the vector of indices to use
* \param[in] distance_field_name the field name that contains the distance values
* \param[in] min_distance the minimum distance a point will be considered from
* \param[in] max_distance the maximum distance a point will be considered to
* \param[out] min_pt the resultant minimum bounds
* \param[out] max_pt the resultant maximum bounds
* \param[in] limit_negative if set to true, then all points outside of the interval (min_distance;max_distace) are considered
* \ingroup filters
*/
template <typename PointT> void
getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
const std::vector<int> &indices,
const std::string &distance_field_name, float min_distance, float max_distance,
Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt, bool limit_negative = false);
/** \brief VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
*
* The VoxelGrid class creates a *3D voxel grid* (think about a voxel
* grid as a set of tiny 3D boxes in space) over the input point cloud data.
* Then, in each *voxel* (i.e., 3D box), all the points present will be
* approximated (i.e., *downsampled*) with their centroid. This approach is
* a bit slower than approximating them with the center of the voxel, but it
* represents the underlying surface more accurately.
*
* \author Radu B. Rusu, Bastian Steder
* \ingroup filters
*/
template <typename PointT>
class VoxelGrid: public Filter<PointT>
{
protected:
using Filter<PointT>::filter_name_;
using Filter<PointT>::getClassName;
using Filter<PointT>::input_;
using Filter<PointT>::indices_;
using PointCloud = typename Filter<PointT>::PointCloud;
using PointCloudPtr = typename PointCloud::Ptr;
using PointCloudConstPtr = typename PointCloud::ConstPtr;
public:
using Ptr = shared_ptr<VoxelGrid<PointT> >;
using ConstPtr = shared_ptr<const VoxelGrid<PointT> >;
/** \brief Empty constructor. */
VoxelGrid () :
leaf_size_ (Eigen::Vector4f::Zero ()),
inverse_leaf_size_ (Eigen::Array4f::Zero ()),
downsample_all_data_ (true),
save_leaf_layout_ (false),
min_b_ (Eigen::Vector4i::Zero ()),
max_b_ (Eigen::Vector4i::Zero ()),
div_b_ (Eigen::Vector4i::Zero ()),
divb_mul_ (Eigen::Vector4i::Zero ()),
filter_field_name_ (""),
filter_limit_min_ (-FLT_MAX),
filter_limit_max_ (FLT_MAX),
filter_limit_negative_ (false),
min_points_per_voxel_ (0)
{
filter_name_ = "VoxelGrid";
}
/** \brief Destructor. */
~VoxelGrid ()
{
}
/** \brief Set the voxel grid leaf size.
* \param[in] leaf_size the voxel grid leaf size
*/
inline void
setLeafSize (const Eigen::Vector4f &leaf_size)
{
leaf_size_ = leaf_size;
// Avoid division errors
if (leaf_size_[3] == 0)
leaf_size_[3] = 1;
// Use multiplications instead of divisions
inverse_leaf_size_ = Eigen::Array4f::Ones () / leaf_size_.array ();
}
/** \brief Set the voxel grid leaf size.
* \param[in] lx the leaf size for X
* \param[in] ly the leaf size for Y
* \param[in] lz the leaf size for Z
*/
inline void
setLeafSize (float lx, float ly, float lz)
{
leaf_size_[0] = lx; leaf_size_[1] = ly; leaf_size_[2] = lz;
// Avoid division errors
if (leaf_size_[3] == 0)
leaf_size_[3] = 1;
// Use multiplications instead of divisions
inverse_leaf_size_ = Eigen::Array4f::Ones () / leaf_size_.array ();
}
/** \brief Get the voxel grid leaf size. */
inline Eigen::Vector3f
getLeafSize () const { return (leaf_size_.head<3> ()); }
/** \brief Set to true if all fields need to be downsampled, or false if just XYZ.
* \param[in] downsample the new value (true/false)
*/
inline void
setDownsampleAllData (bool downsample) { downsample_all_data_ = downsample; }
/** \brief Get the state of the internal downsampling parameter (true if
* all fields need to be downsampled, false if just XYZ).
*/
inline bool
getDownsampleAllData () const { return (downsample_all_data_); }
/** \brief Set the minimum number of points required for a voxel to be used.
* \param[in] min_points_per_voxel the minimum number of points for required for a voxel to be used
*/
inline void
setMinimumPointsNumberPerVoxel (unsigned int min_points_per_voxel) { min_points_per_voxel_ = min_points_per_voxel; }
/** \brief Return the minimum number of points required for a voxel to be used.
*/
inline unsigned int
getMinimumPointsNumberPerVoxel () const { return min_points_per_voxel_; }
/** \brief Set to true if leaf layout information needs to be saved for later access.
* \param[in] save_leaf_layout the new value (true/false)
*/
inline void
setSaveLeafLayout (bool save_leaf_layout) { save_leaf_layout_ = save_leaf_layout; }
/** \brief Returns true if leaf layout information will to be saved for later access. */
inline bool
getSaveLeafLayout () const { return (save_leaf_layout_); }
/** \brief Get the minimum coordinates of the bounding box (after
* filtering is performed).
*/
inline Eigen::Vector3i
getMinBoxCoordinates () const { return (min_b_.head<3> ()); }
/** \brief Get the minimum coordinates of the bounding box (after
* filtering is performed).
*/
inline Eigen::Vector3i
getMaxBoxCoordinates () const { return (max_b_.head<3> ()); }
/** \brief Get the number of divisions along all 3 axes (after filtering
* is performed).
*/
inline Eigen::Vector3i
getNrDivisions () const { return (div_b_.head<3> ()); }
/** \brief Get the multipliers to be applied to the grid coordinates in
* order to find the centroid index (after filtering is performed).
*/
inline Eigen::Vector3i
getDivisionMultiplier () const { return (divb_mul_.head<3> ()); }
/** \brief Returns the index in the resulting downsampled cloud of the specified point.
*
* \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering
* performed, and that the point is inside the grid, to avoid invalid access (or use
* getGridCoordinates+getCentroidIndexAt)
*
* \param[in] p the point to get the index at
*/
inline int
getCentroidIndex (const PointT &p) const
{
return (leaf_layout_.at ((Eigen::Vector4i (static_cast<int> (std::floor (p.x * inverse_leaf_size_[0])),
static_cast<int> (std::floor (p.y * inverse_leaf_size_[1])),
static_cast<int> (std::floor (p.z * inverse_leaf_size_[2])), 0) - min_b_).dot (divb_mul_)));
}
/** \brief Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinates,
* relative to the grid coordinates of the specified point (or -1 if the cell was empty/out of bounds).
* \param[in] reference_point the coordinates of the reference point (corresponding cell is allowed to be empty/out of bounds)
* \param[in] relative_coordinates matrix with the columns being the coordinates of the requested cells, relative to the reference point's cell
* \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering performed
*/
inline std::vector<int>
getNeighborCentroidIndices (const PointT &reference_point, const Eigen::MatrixXi &relative_coordinates) const
{
Eigen::Vector4i ijk (static_cast<int> (std::floor (reference_point.x * inverse_leaf_size_[0])),
static_cast<int> (std::floor (reference_point.y * inverse_leaf_size_[1])),
static_cast<int> (std::floor (reference_point.z * inverse_leaf_size_[2])), 0);
Eigen::Array4i diff2min = min_b_ - ijk;
Eigen::Array4i diff2max = max_b_ - ijk;
std::vector<int> neighbors (relative_coordinates.cols());
for (Eigen::Index ni = 0; ni < relative_coordinates.cols (); ni++)
{
Eigen::Vector4i displacement = (Eigen::Vector4i() << relative_coordinates.col(ni), 0).finished();
// checking if the specified cell is in the grid
if ((diff2min <= displacement.array()).all() && (diff2max >= displacement.array()).all())
neighbors[ni] = leaf_layout_[((ijk + displacement - min_b_).dot (divb_mul_))]; // .at() can be omitted
else
neighbors[ni] = -1; // cell is out of bounds, consider it empty
}
return (neighbors);
}
/** \brief Returns the layout of the leafs for fast access to cells relative to current position.
* \note position at (i-min_x) + (j-min_y)*div_x + (k-min_z)*div_x*div_y holds the index of the element at coordinates (i,j,k) in the grid (-1 if empty)
*/
inline std::vector<int>
getLeafLayout () const { return (leaf_layout_); }
/** \brief Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
* \param[in] x the X point coordinate to get the (i, j, k) index at
* \param[in] y the Y point coordinate to get the (i, j, k) index at
* \param[in] z the Z point coordinate to get the (i, j, k) index at
*/
inline Eigen::Vector3i
getGridCoordinates (float x, float y, float z) const
{
return (Eigen::Vector3i (static_cast<int> (std::floor (x * inverse_leaf_size_[0])),
static_cast<int> (std::floor (y * inverse_leaf_size_[1])),
static_cast<int> (std::floor (z * inverse_leaf_size_[2]))));
}
/** \brief Returns the index in the downsampled cloud corresponding to a given set of coordinates.
* \param[in] ijk the coordinates (i,j,k) in the grid (-1 if empty)
*/
inline int
getCentroidIndexAt (const Eigen::Vector3i &ijk) const
{
int idx = ((Eigen::Vector4i() << ijk, 0).finished() - min_b_).dot (divb_mul_);
if (idx < 0 || idx >= static_cast<int> (leaf_layout_.size ())) // this checks also if leaf_layout_.size () == 0 i.e. everything was computed as needed
{
//if (verbose)
// PCL_ERROR ("[pcl::%s::getCentroidIndexAt] Specified coordinate is outside grid bounds, or leaf layout is not saved, make sure to call setSaveLeafLayout(true) and filter(output) first!\n", getClassName ().c_str ());
return (-1);
}
return (leaf_layout_[idx]);
}
/** \brief Provide the name of the field to be used for filtering data. In conjunction with \a setFilterLimits,
* points having values outside this interval will be discarded.
* \param[in] field_name the name of the field that contains values used for filtering
*/
inline void
setFilterFieldName (const std::string &field_name)
{
filter_field_name_ = field_name;
}
/** \brief Get the name of the field used for filtering. */
inline std::string const
getFilterFieldName () const
{
return (filter_field_name_);
}
/** \brief Set the field filter limits. All points having field values outside this interval will be discarded.
* \param[in] limit_min the minimum allowed field value
* \param[in] limit_max the maximum allowed field value
*/
inline void
setFilterLimits (const double &limit_min, const double &limit_max)
{
filter_limit_min_ = limit_min;
filter_limit_max_ = limit_max;
}
/** \brief Get the field filter limits (min/max) set by the user. The default values are -FLT_MAX, FLT_MAX.
* \param[out] limit_min the minimum allowed field value
* \param[out] limit_max the maximum allowed field value
*/
inline void
getFilterLimits (double &limit_min, double &limit_max) const
{
limit_min = filter_limit_min_;
limit_max = filter_limit_max_;
}
/** \brief Set to true if we want to return the data outside the interval specified by setFilterLimits (min, max).
* Default: false.
* \param[in] limit_negative return data inside the interval (false) or outside (true)
*/
inline void
setFilterLimitsNegative (const bool limit_negative)
{
filter_limit_negative_ = limit_negative;
}
/** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
* \param[out] limit_negative true if data \b outside the interval [min; max] is to be returned, false otherwise
*/
inline void
getFilterLimitsNegative (bool &limit_negative) const
{
limit_negative = filter_limit_negative_;
}
/** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
* \return true if data \b outside the interval [min; max] is to be returned, false otherwise
*/
inline bool
getFilterLimitsNegative () const
{
return (filter_limit_negative_);
}
protected:
/** \brief The size of a leaf. */
Eigen::Vector4f leaf_size_;
/** \brief Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons. */
Eigen::Array4f inverse_leaf_size_;
/** \brief Set to true if all fields need to be downsampled, or false if just XYZ. */
bool downsample_all_data_;
/** \brief Set to true if leaf layout information needs to be saved in \a leaf_layout_. */
bool save_leaf_layout_;
/** \brief The leaf layout information for fast access to cells relative to current position **/
std::vector<int> leaf_layout_;
/** \brief The minimum and maximum bin coordinates, the number of divisions, and the division multiplier. */
Eigen::Vector4i min_b_, max_b_, div_b_, divb_mul_;
/** \brief The desired user filter field name. */
std::string filter_field_name_;
/** \brief The minimum allowed filter value a point will be considered from. */
double filter_limit_min_;
/** \brief The maximum allowed filter value a point will be considered from. */
double filter_limit_max_;
/** \brief Set to true if we want to return the data outside (\a filter_limit_min_;\a filter_limit_max_). Default: false. */
bool filter_limit_negative_;
/** \brief Minimum number of points per voxel for the centroid to be computed */
unsigned int min_points_per_voxel_;
using FieldList = typename pcl::traits::fieldList<PointT>::type;
/** \brief Downsample a Point Cloud using a voxelized grid approach
* \param[out] output the resultant point cloud message
*/
void
applyFilter (PointCloud &output) override;
};
/** \brief VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
*
* The VoxelGrid class creates a *3D voxel grid* (think about a voxel
* grid as a set of tiny 3D boxes in space) over the input point cloud data.
* Then, in each *voxel* (i.e., 3D box), all the points present will be
* approximated (i.e., *downsampled*) with their centroid. This approach is
* a bit slower than approximating them with the center of the voxel, but it
* represents the underlying surface more accurately.
*
* \author Radu B. Rusu, Bastian Steder, Radoslaw Cybulski
* \ingroup filters
*/
template <>
class PCL_EXPORTS VoxelGrid<pcl::PCLPointCloud2> : public Filter<pcl::PCLPointCloud2>
{
using Filter<pcl::PCLPointCloud2>::filter_name_;
using Filter<pcl::PCLPointCloud2>::getClassName;
using PCLPointCloud2 = pcl::PCLPointCloud2;
using PCLPointCloud2Ptr = PCLPointCloud2::Ptr;
using PCLPointCloud2ConstPtr = PCLPointCloud2::ConstPtr;
public:
/** \brief Empty constructor. */
VoxelGrid () :
leaf_size_ (Eigen::Vector4f::Zero ()),
inverse_leaf_size_ (Eigen::Array4f::Zero ()),
downsample_all_data_ (true),
save_leaf_layout_ (false),
min_b_ (Eigen::Vector4i::Zero ()),
max_b_ (Eigen::Vector4i::Zero ()),
div_b_ (Eigen::Vector4i::Zero ()),
divb_mul_ (Eigen::Vector4i::Zero ()),
filter_field_name_ (""),
filter_limit_min_ (-FLT_MAX),
filter_limit_max_ (FLT_MAX),
filter_limit_negative_ (false),
min_points_per_voxel_ (0)
{
filter_name_ = "VoxelGrid";
}
/** \brief Destructor. */
~VoxelGrid ()
{
}
/** \brief Set the voxel grid leaf size.
* \param[in] leaf_size the voxel grid leaf size
*/
inline void
setLeafSize (const Eigen::Vector4f &leaf_size)
{
leaf_size_ = leaf_size;
// Avoid division errors
if (leaf_size_[3] == 0)
leaf_size_[3] = 1;
// Use multiplications instead of divisions
inverse_leaf_size_ = Eigen::Array4f::Ones () / leaf_size_.array ();
}
/** \brief Set the voxel grid leaf size.
* \param[in] lx the leaf size for X
* \param[in] ly the leaf size for Y
* \param[in] lz the leaf size for Z
*/
inline void
setLeafSize (float lx, float ly, float lz)
{
leaf_size_[0] = lx; leaf_size_[1] = ly; leaf_size_[2] = lz;
// Avoid division errors
if (leaf_size_[3] == 0)
leaf_size_[3] = 1;
// Use multiplications instead of divisions
inverse_leaf_size_ = Eigen::Array4f::Ones () / leaf_size_.array ();
}
/** \brief Get the voxel grid leaf size. */
inline Eigen::Vector3f
getLeafSize () const { return (leaf_size_.head<3> ()); }
/** \brief Set to true if all fields need to be downsampled, or false if just XYZ.
* \param[in] downsample the new value (true/false)
*/
inline void
setDownsampleAllData (bool downsample) { downsample_all_data_ = downsample; }
/** \brief Get the state of the internal downsampling parameter (true if
* all fields need to be downsampled, false if just XYZ).
*/
inline bool
getDownsampleAllData () const { return (downsample_all_data_); }
/** \brief Set the minimum number of points required for a voxel to be used.
* \param[in] min_points_per_voxel the minimum number of points for required for a voxel to be used
*/
inline void
setMinimumPointsNumberPerVoxel (unsigned int min_points_per_voxel) { min_points_per_voxel_ = min_points_per_voxel; }
/** \brief Return the minimum number of points required for a voxel to be used.
*/
inline unsigned int
getMinimumPointsNumberPerVoxel () const { return min_points_per_voxel_; }
/** \brief Set to true if leaf layout information needs to be saved for later access.
* \param[in] save_leaf_layout the new value (true/false)
*/
inline void
setSaveLeafLayout (bool save_leaf_layout) { save_leaf_layout_ = save_leaf_layout; }
/** \brief Returns true if leaf layout information will to be saved for later access. */
inline bool
getSaveLeafLayout () const { return (save_leaf_layout_); }
/** \brief Get the minimum coordinates of the bounding box (after
* filtering is performed).
*/
inline Eigen::Vector3i
getMinBoxCoordinates () const { return (min_b_.head<3> ()); }
/** \brief Get the minimum coordinates of the bounding box (after
* filtering is performed).
*/
inline Eigen::Vector3i
getMaxBoxCoordinates () const { return (max_b_.head<3> ()); }
/** \brief Get the number of divisions along all 3 axes (after filtering
* is performed).
*/
inline Eigen::Vector3i
getNrDivisions () const { return (div_b_.head<3> ()); }
/** \brief Get the multipliers to be applied to the grid coordinates in
* order to find the centroid index (after filtering is performed).
*/
inline Eigen::Vector3i
getDivisionMultiplier () const { return (divb_mul_.head<3> ()); }
/** \brief Returns the index in the resulting downsampled cloud of the specified point.
* \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering performed,
* and that the point is inside the grid, to avoid invalid access (or use getGridCoordinates+getCentroidIndexAt)
* \param[in] x the X point coordinate to get the index at
* \param[in] y the Y point coordinate to get the index at
* \param[in] z the Z point coordinate to get the index at
*/
inline int
getCentroidIndex (float x, float y, float z) const
{
return (leaf_layout_.at ((Eigen::Vector4i (static_cast<int> (std::floor (x * inverse_leaf_size_[0])),
static_cast<int> (std::floor (y * inverse_leaf_size_[1])),
static_cast<int> (std::floor (z * inverse_leaf_size_[2])),
0)
- min_b_).dot (divb_mul_)));
}
/** \brief Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinates,
* relative to the grid coordinates of the specified point (or -1 if the cell was empty/out of bounds).
* \param[in] x the X coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
* \param[in] y the Y coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
* \param[in] z the Z coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
* \param[out] relative_coordinates matrix with the columns being the coordinates of the requested cells, relative to the reference point's cell
* \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering performed
*/
inline std::vector<int>
getNeighborCentroidIndices (float x, float y, float z, const Eigen::MatrixXi &relative_coordinates) const
{
Eigen::Vector4i ijk (static_cast<int> (std::floor (x * inverse_leaf_size_[0])),
static_cast<int> (std::floor (y * inverse_leaf_size_[1])),
static_cast<int> (std::floor (z * inverse_leaf_size_[2])), 0);
Eigen::Array4i diff2min = min_b_ - ijk;
Eigen::Array4i diff2max = max_b_ - ijk;
std::vector<int> neighbors (relative_coordinates.cols());
for (Eigen::Index ni = 0; ni < relative_coordinates.cols (); ni++)
{
Eigen::Vector4i displacement = (Eigen::Vector4i() << relative_coordinates.col(ni), 0).finished();
// checking if the specified cell is in the grid
if ((diff2min <= displacement.array()).all() && (diff2max >= displacement.array()).all())
neighbors[ni] = leaf_layout_[((ijk + displacement - min_b_).dot (divb_mul_))]; // .at() can be omitted
else
neighbors[ni] = -1; // cell is out of bounds, consider it empty
}
return (neighbors);
}
/** \brief Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinates,
* relative to the grid coordinates of the specified point (or -1 if the cell was empty/out of bounds).
* \param[in] x the X coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
* \param[in] y the Y coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
* \param[in] z the Z coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
* \param[out] relative_coordinates vector with the elements being the coordinates of the requested cells, relative to the reference point's cell
* \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering performed
*/
inline std::vector<int>
getNeighborCentroidIndices (float x, float y, float z, const std::vector<Eigen::Vector3i, Eigen::aligned_allocator<Eigen::Vector3i> > &relative_coordinates) const
{
Eigen::Vector4i ijk (static_cast<int> (std::floor (x * inverse_leaf_size_[0])), static_cast<int> (std::floor (y * inverse_leaf_size_[1])), static_cast<int> (std::floor (z * inverse_leaf_size_[2])), 0);
std::vector<int> neighbors;
neighbors.reserve (relative_coordinates.size ());
for (const auto &relative_coordinate : relative_coordinates)
neighbors.push_back (leaf_layout_[(ijk + (Eigen::Vector4i() << relative_coordinate, 0).finished() - min_b_).dot (divb_mul_)]);
return (neighbors);
}
/** \brief Returns the layout of the leafs for fast access to cells relative to current position.
* \note position at (i-min_x) + (j-min_y)*div_x + (k-min_z)*div_x*div_y holds the index of the element at coordinates (i,j,k) in the grid (-1 if empty)
*/
inline std::vector<int>
getLeafLayout () const { return (leaf_layout_); }
/** \brief Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
* \param[in] x the X point coordinate to get the (i, j, k) index at
* \param[in] y the Y point coordinate to get the (i, j, k) index at
* \param[in] z the Z point coordinate to get the (i, j, k) index at
*/
inline Eigen::Vector3i
getGridCoordinates (float x, float y, float z) const
{
return (Eigen::Vector3i (static_cast<int> (std::floor (x * inverse_leaf_size_[0])),
static_cast<int> (std::floor (y * inverse_leaf_size_[1])),
static_cast<int> (std::floor (z * inverse_leaf_size_[2]))));
}
/** \brief Returns the index in the downsampled cloud corresponding to a given set of coordinates.
* \param[in] ijk the coordinates (i,j,k) in the grid (-1 if empty)
*/
inline int
getCentroidIndexAt (const Eigen::Vector3i &ijk) const
{
int idx = ((Eigen::Vector4i() << ijk, 0).finished() - min_b_).dot (divb_mul_);
if (idx < 0 || idx >= static_cast<int> (leaf_layout_.size ())) // this checks also if leaf_layout_.size () == 0 i.e. everything was computed as needed
{
//if (verbose)
// PCL_ERROR ("[pcl::%s::getCentroidIndexAt] Specified coordinate is outside grid bounds, or leaf layout is not saved, make sure to call setSaveLeafLayout(true) and filter(output) first!\n", getClassName ().c_str ());
return (-1);
}
return (leaf_layout_[idx]);
}
/** \brief Provide the name of the field to be used for filtering data. In conjunction with \a setFilterLimits,
* points having values outside this interval will be discarded.
* \param[in] field_name the name of the field that contains values used for filtering
*/
inline void
setFilterFieldName (const std::string &field_name)
{
filter_field_name_ = field_name;
}
/** \brief Get the name of the field used for filtering. */
inline std::string const
getFilterFieldName () const
{
return (filter_field_name_);
}
/** \brief Set the field filter limits. All points having field values outside this interval will be discarded.
* \param[in] limit_min the minimum allowed field value
* \param[in] limit_max the maximum allowed field value
*/
inline void
setFilterLimits (const double &limit_min, const double &limit_max)
{
filter_limit_min_ = limit_min;
filter_limit_max_ = limit_max;
}
/** \brief Get the field filter limits (min/max) set by the user. The default values are -FLT_MAX, FLT_MAX.
* \param[out] limit_min the minimum allowed field value
* \param[out] limit_max the maximum allowed field value
*/
inline void
getFilterLimits (double &limit_min, double &limit_max) const
{
limit_min = filter_limit_min_;
limit_max = filter_limit_max_;
}
/** \brief Set to true if we want to return the data outside the interval specified by setFilterLimits (min, max).
* Default: false.
* \param[in] limit_negative return data inside the interval (false) or outside (true)
*/
inline void
setFilterLimitsNegative (const bool limit_negative)
{
filter_limit_negative_ = limit_negative;
}
/** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
* \param[out] limit_negative true if data \b outside the interval [min; max] is to be returned, false otherwise
*/
inline void
getFilterLimitsNegative (bool &limit_negative) const
{
limit_negative = filter_limit_negative_;
}
/** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
* \return true if data \b outside the interval [min; max] is to be returned, false otherwise
*/
inline bool
getFilterLimitsNegative () const
{
return (filter_limit_negative_);
}
protected:
/** \brief The size of a leaf. */
Eigen::Vector4f leaf_size_;
/** \brief Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons. */
Eigen::Array4f inverse_leaf_size_;
/** \brief Set to true if all fields need to be downsampled, or false if just XYZ. */
bool downsample_all_data_;
/** \brief Set to true if leaf layout information needs to be saved in \a
* leaf_layout.
*/
bool save_leaf_layout_;
/** \brief The leaf layout information for fast access to cells relative
* to current position
*/
std::vector<int> leaf_layout_;
/** \brief The minimum and maximum bin coordinates, the number of
* divisions, and the division multiplier.
*/
Eigen::Vector4i min_b_, max_b_, div_b_, divb_mul_;
/** \brief The desired user filter field name. */
std::string filter_field_name_;
/** \brief The minimum allowed filter value a point will be considered from. */
double filter_limit_min_;
/** \brief The maximum allowed filter value a point will be considered from. */
double filter_limit_max_;
/** \brief Set to true if we want to return the data outside (\a filter_limit_min_;\a filter_limit_max_). Default: false. */
bool filter_limit_negative_;
/** \brief Minimum number of points per voxel for the centroid to be computed */
unsigned int min_points_per_voxel_;
/** \brief Downsample a Point Cloud using a voxelized grid approach
* \param[out] output the resultant point cloud
*/
void
applyFilter (PCLPointCloud2 &output) override;
};
}
#ifdef PCL_NO_PRECOMPILE
#include <pcl/filters/impl/voxel_grid.hpp>
#endif
pcl::VoxelGrid
VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
Definition: voxel_grid.h:177
pcl::VoxelGrid::getMinBoxCoordinates
Eigen::Vector3i getMinBoxCoordinates() const
Get the minimum coordinates of the bounding box (after filtering is performed).
Definition: voxel_grid.h:289
pcl::VoxelGrid< pcl::PCLPointCloud2 >::leaf_size_
Eigen::Vector4f leaf_size_
The size of a leaf.
Definition: voxel_grid.h:804
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::VoxelGrid< pcl::PCLPointCloud2 >::min_b_
Eigen::Vector4i min_b_
The minimum and maximum bin coordinates, the number of divisions, and the division multiplier.
Definition: voxel_grid.h:825
pcl::VoxelGrid::getLeafLayout
std::vector< int > getLeafLayout() const
Returns the layout of the leafs for fast access to cells relative to current position.
Definition: voxel_grid.h:356
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getLeafLayout
std::vector< int > getLeafLayout() const
Returns the layout of the leafs for fast access to cells relative to current position.
Definition: voxel_grid.h:704
pcl::VoxelGrid::getCentroidIndexAt
int getCentroidIndexAt(const Eigen::Vector3i &ijk) const
Returns the index in the downsampled cloud corresponding to a given set of coordinates.
Definition: voxel_grid.h:375
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getMaxBoxCoordinates
Eigen::Vector3i getMaxBoxCoordinates() const
Get the minimum coordinates of the bounding box (after filtering is performed).
Definition: voxel_grid.h:621
pcl::VoxelGrid::setFilterLimitsNegative
void setFilterLimitsNegative(const bool limit_negative)
Set to true if we want to return the data outside the interval specified by setFilterLimits (min,...
Definition: voxel_grid.h:431
pcl::Filter< pcl::PointXYZRGBL >::Ptr
shared_ptr< Filter< pcl::PointXYZRGBL > > Ptr
Definition: filter.h:89
Eigen
Definition: bfgs.h:9
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getDownsampleAllData
bool getDownsampleAllData() const
Get the state of the internal downsampling parameter (true if all fields need to be downsampled,...
Definition: voxel_grid.h:588
pcl::PCLBase< pcl::PointXYZRGBL >::PointCloudConstPtr
typename PointCloud::ConstPtr PointCloudConstPtr
Definition: pcl_base.h:74
pcl::VoxelGrid::setDownsampleAllData
void setDownsampleAllData(bool downsample)
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:256
pcl::VoxelGrid::applyFilter
void applyFilter(PointCloud &output) override
Downsample a Point Cloud using a voxelized grid approach.
Definition: voxel_grid.hpp:214
pcl::PCLBase< pcl::PointXYZRGBL >::PointCloudPtr
typename PointCloud::Ptr PointCloudPtr
Definition: pcl_base.h:73
pcl::VoxelGrid< pcl::PCLPointCloud2 >::setSaveLeafLayout
void setSaveLeafLayout(bool save_leaf_layout)
Set to true if leaf layout information needs to be saved for later access.
Definition: voxel_grid.h:605
pcl::VoxelGrid< pcl::PCLPointCloud2 >::setFilterLimitsNegative
void setFilterLimitsNegative(const bool limit_negative)
Set to true if we want to return the data outside the interval specified by setFilterLimits (min,...
Definition: voxel_grid.h:779
pcl::PCLPointCloud2::Ptr
shared_ptr< ::pcl::PCLPointCloud2 > Ptr
Definition: PCLPointCloud2.h:38
pcl::VoxelGrid::getDivisionMultiplier
Eigen::Vector3i getDivisionMultiplier() const
Get the multipliers to be applied to the grid coordinates in order to find the centroid index (after ...
Definition: voxel_grid.h:307
pcl::getHalfNeighborCellIndices
Eigen::MatrixXi getHalfNeighborCellIndices()
Get the relative cell indices of the "upper half" 13 neighbors.
Definition: voxel_grid.h:84
pcl::VoxelGrid::VoxelGrid
VoxelGrid()
Empty constructor.
Definition: voxel_grid.h:195
pcl::VoxelGrid::setLeafSize
void setLeafSize(const Eigen::Vector4f &leaf_size)
Set the voxel grid leaf size.
Definition: voxel_grid.h:222
pcl::VoxelGrid< pcl::PCLPointCloud2 >::setFilterLimits
void setFilterLimits(const double &limit_min, const double &limit_max)
Set the field filter limits.
Definition: voxel_grid.h:757
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getFilterLimits
void getFilterLimits(double &limit_min, double &limit_max) const
Get the field filter limits (min/max) set by the user.
Definition: voxel_grid.h:768
pcl::VoxelGrid::getGridCoordinates
Eigen::Vector3i getGridCoordinates(float x, float y, float z) const
Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
Definition: voxel_grid.h:364
pcl::VoxelGrid< pcl::PCLPointCloud2 >::setFilterFieldName
void setFilterFieldName(const std::string &field_name)
Provide the name of the field to be used for filtering data.
Definition: voxel_grid.h:740
pcl::VoxelGrid::filter_limit_max_
double filter_limit_max_
The maximum allowed filter value a point will be considered from.
Definition: voxel_grid.h:480
pcl::VoxelGrid::setFilterLimits
void setFilterLimits(const double &limit_min, const double &limit_max)
Set the field filter limits.
Definition: voxel_grid.h:409
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getCentroidIndexAt
int getCentroidIndexAt(const Eigen::Vector3i &ijk) const
Returns the index in the downsampled cloud corresponding to a given set of coordinates.
Definition: voxel_grid.h:723
pcl::VoxelGrid::downsample_all_data_
bool downsample_all_data_
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:462
pcl::VoxelGrid::getCentroidIndex
int getCentroidIndex(const PointT &p) const
Returns the index in the resulting downsampled cloud of the specified point.
Definition: voxel_grid.h:318
pcl::VoxelGrid< pcl::PCLPointCloud2 >::downsample_all_data_
bool downsample_all_data_
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:810
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getMinBoxCoordinates
Eigen::Vector3i getMinBoxCoordinates() const
Get the minimum coordinates of the bounding box (after filtering is performed).
Definition: voxel_grid.h:615
pcl::VoxelGrid< pcl::PCLPointCloud2 >::leaf_layout_
std::vector< int > leaf_layout_
The leaf layout information for fast access to cells relative to current position.
Definition: voxel_grid.h:820
pcl::PCLBase< pcl::PCLPointCloud2 >::PCLPointCloud2ConstPtr
PCLPointCloud2::ConstPtr PCLPointCloud2ConstPtr
Definition: pcl_base.h:190
pcl::VoxelGrid::filter_limit_negative_
bool filter_limit_negative_
Set to true if we want to return the data outside (filter_limit_min_;filter_limit_max_).
Definition: voxel_grid.h:483
pcl::PointCloud< pcl::PointXYZRGBL >
pcl::VoxelGrid::inverse_leaf_size_
Eigen::Array4f inverse_leaf_size_
Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons.
Definition: voxel_grid.h:459
pcl::VoxelGrid< pcl::PointXYZRGBL >::FieldList
typename pcl::traits::fieldList< pcl::PointXYZRGBL >::type FieldList
Definition: voxel_grid.h:488
pcl::VoxelGrid::getFilterLimitsNegative
void getFilterLimitsNegative(bool &limit_negative) const
Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
Definition: voxel_grid.h:440
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getFilterLimitsNegative
void getFilterLimitsNegative(bool &limit_negative) const
Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
Definition: voxel_grid.h:788
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:623
pcl::VoxelGrid< pcl::PCLPointCloud2 >::setMinimumPointsNumberPerVoxel
void setMinimumPointsNumberPerVoxel(unsigned int min_points_per_voxel)
Set the minimum number of points required for a voxel to be used.
Definition: voxel_grid.h:594
pcl::getAllNeighborCellIndices
Eigen::MatrixXi getAllNeighborCellIndices()
Get the relative cell indices of all the 26 neighbors.
Definition: voxel_grid.h:121
pcl::VoxelGrid::save_leaf_layout_
bool save_leaf_layout_
Set to true if leaf layout information needs to be saved in leaf_layout_.
Definition: voxel_grid.h:465
pcl::VoxelGrid::getSaveLeafLayout
bool getSaveLeafLayout() const
Returns true if leaf layout information will to be saved for later access.
Definition: voxel_grid.h:283
pcl::VoxelGrid::getFilterLimits
void getFilterLimits(double &limit_min, double &limit_max) const
Get the field filter limits (min/max) set by the user.
Definition: voxel_grid.h:420
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getFilterFieldName
const std::string getFilterFieldName() const
Get the name of the field used for filtering.
Definition: voxel_grid.h:747
pcl::PCLPointCloud2ConstPtr
PCLPointCloud2::ConstPtr PCLPointCloud2ConstPtr
Definition: PCLPointCloud2.h:94
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getSaveLeafLayout
bool getSaveLeafLayout() const
Returns true if leaf layout information will to be saved for later access.
Definition: voxel_grid.h:609
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getMinimumPointsNumberPerVoxel
unsigned int getMinimumPointsNumberPerVoxel() const
Return the minimum number of points required for a voxel to be used.
Definition: voxel_grid.h:599
pcl::VoxelGrid< pcl::PCLPointCloud2 >::~VoxelGrid
~VoxelGrid()
Destructor.
Definition: voxel_grid.h:540
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getLeafSize
Eigen::Vector3f getLeafSize() const
Get the voxel grid leaf size.
Definition: voxel_grid.h:576
pcl::PCLBase< pcl::PCLPointCloud2 >::PCLPointCloud2Ptr
PCLPointCloud2::Ptr PCLPointCloud2Ptr
Definition: pcl_base.h:189
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getNrDivisions
Eigen::Vector3i getNrDivisions() const
Get the number of divisions along all 3 axes (after filtering is performed).
Definition: voxel_grid.h:627
pcl::VoxelGrid::getMinimumPointsNumberPerVoxel
unsigned int getMinimumPointsNumberPerVoxel() const
Return the minimum number of points required for a voxel to be used.
Definition: voxel_grid.h:273
pcl::VoxelGrid< pcl::PCLPointCloud2 >::filter_limit_max_
double filter_limit_max_
The maximum allowed filter value a point will be considered from.
Definition: voxel_grid.h:834
pcl::PCLPointCloud2::ConstPtr
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
Definition: PCLPointCloud2.h:39
pcl::VoxelGrid< pcl::PCLPointCloud2 >::min_points_per_voxel_
unsigned int min_points_per_voxel_
Minimum number of points per voxel for the centroid to be computed.
Definition: voxel_grid.h:840
pcl::VoxelGrid::setLeafSize
void setLeafSize(float lx, float ly, float lz)
Set the voxel grid leaf size.
Definition: voxel_grid.h:238
pcl::VoxelGrid::getFilterFieldName
const std::string getFilterFieldName() const
Get the name of the field used for filtering.
Definition: voxel_grid.h:399
pcl::VoxelGrid::filter_field_name_
std::string filter_field_name_
The desired user filter field name.
Definition: voxel_grid.h:474
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getGridCoordinates
Eigen::Vector3i getGridCoordinates(float x, float y, float z) const
Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
Definition: voxel_grid.h:712
pcl::VoxelGrid::filter_limit_min_
double filter_limit_min_
The minimum allowed filter value a point will be considered from.
Definition: voxel_grid.h:477
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getDivisionMultiplier
Eigen::Vector3i getDivisionMultiplier() const
Get the multipliers to be applied to the grid coordinates in order to find the centroid index (after ...
Definition: voxel_grid.h:633
pcl::VoxelGrid::min_b_
Eigen::Vector4i min_b_
The minimum and maximum bin coordinates, the number of divisions, and the division multiplier.
Definition: voxel_grid.h:471
pcl::VoxelGrid::getMaxBoxCoordinates
Eigen::Vector3i getMaxBoxCoordinates() const
Get the minimum coordinates of the bounding box (after filtering is performed).
Definition: voxel_grid.h:295
pcl::Filter< pcl::PointXYZRGBL >::ConstPtr
shared_ptr< const Filter< pcl::PointXYZRGBL > > ConstPtr
Definition: filter.h:90
pcl::VoxelGrid< pcl::PCLPointCloud2 >::VoxelGrid
VoxelGrid()
Empty constructor.
Definition: voxel_grid.h:521
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getFilterLimitsNegative
bool getFilterLimitsNegative() const
Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
Definition: voxel_grid.h:797
pcl::VoxelGrid::~VoxelGrid
~VoxelGrid()
Destructor.
Definition: voxel_grid.h:214
pcl::Filter
Filter represents the base filter class.
Definition: filter.h:83
pcl::VoxelGrid::div_b_
Eigen::Vector4i div_b_
Definition: voxel_grid.h:471
pcl::VoxelGrid::getNeighborCentroidIndices
std::vector< int > getNeighborCentroidIndices(const PointT &reference_point, const Eigen::MatrixXi &relative_coordinates) const
Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinate...
Definition: voxel_grid.h:332
pcl::VoxelGrid::divb_mul_
Eigen::Vector4i divb_mul_
Definition: voxel_grid.h:471
pcl::PCLPointCloud2
Definition: PCLPointCloud2.h:19
pcl::VoxelGrid::getFilterLimitsNegative
bool getFilterLimitsNegative() const
Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
Definition: voxel_grid.h:449
pcl::Filter::filter_name_
std::string filter_name_
The filter name.
Definition: filter.h:164
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:415
pcl::getMinMax3D
void getMinMax3D(const pcl::PointCloud< PointT > &cloud, PointT &min_pt, PointT &max_pt)
Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud.
Definition: common.hpp:242
pcl::VoxelGrid< pcl::PCLPointCloud2 >::inverse_leaf_size_
Eigen::Array4f inverse_leaf_size_
Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons.
Definition: voxel_grid.h:807
pcl::VoxelGrid::leaf_layout_
std::vector< int > leaf_layout_
The leaf layout information for fast access to cells relative to current position.
Definition: voxel_grid.h:468
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getNeighborCentroidIndices
std::vector< int > getNeighborCentroidIndices(float x, float y, float z, const Eigen::MatrixXi &relative_coordinates) const
Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinate...
Definition: voxel_grid.h:661
pcl::VoxelGrid::leaf_size_
Eigen::Vector4f leaf_size_
The size of a leaf.
Definition: voxel_grid.h:456
pcl::VoxelGrid< pcl::PCLPointCloud2 >::setDownsampleAllData
void setDownsampleAllData(bool downsample)
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:582
pcl::VoxelGrid< pcl::PCLPointCloud2 >::save_leaf_layout_
bool save_leaf_layout_
Set to true if leaf layout information needs to be saved in leaf_layout.
Definition: voxel_grid.h:815
pcl::VoxelGrid< pcl::PCLPointCloud2 >::filter_limit_negative_
bool filter_limit_negative_
Set to true if we want to return the data outside (filter_limit_min_;filter_limit_max_).
Definition: voxel_grid.h:837
pcl::PointCloud::ConstPtr
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:416
pcl::VoxelGrid::setMinimumPointsNumberPerVoxel
void setMinimumPointsNumberPerVoxel(unsigned int min_points_per_voxel)
Set the minimum number of points required for a voxel to be used.
Definition: voxel_grid.h:268
pcl::VoxelGrid::setFilterFieldName
void setFilterFieldName(const std::string &field_name)
Provide the name of the field to be used for filtering data.
Definition: voxel_grid.h:392
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getNeighborCentroidIndices
std::vector< int > getNeighborCentroidIndices(float x, float y, float z, const std::vector< Eigen::Vector3i, Eigen::aligned_allocator< Eigen::Vector3i > > &relative_coordinates) const
Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinate...
Definition: voxel_grid.h:690
pcl::VoxelGrid< pcl::PCLPointCloud2 >::setLeafSize
void setLeafSize(float lx, float ly, float lz)
Set the voxel grid leaf size.
Definition: voxel_grid.h:564
pcl::VoxelGrid< pcl::PCLPointCloud2 >::filter_field_name_
std::string filter_field_name_
The desired user filter field name.
Definition: voxel_grid.h:828
pcl::VoxelGrid::max_b_
Eigen::Vector4i max_b_
Definition: voxel_grid.h:471
pcl::VoxelGrid::setSaveLeafLayout
void setSaveLeafLayout(bool save_leaf_layout)
Set to true if leaf layout information needs to be saved for later access.
Definition: voxel_grid.h:279
pcl::VoxelGrid::getNrDivisions
Eigen::Vector3i getNrDivisions() const
Get the number of divisions along all 3 axes (after filtering is performed).
Definition: voxel_grid.h:301
pcl::VoxelGrid::getDownsampleAllData
bool getDownsampleAllData() const
Get the state of the internal downsampling parameter (true if all fields need to be downsampled,...
Definition: voxel_grid.h:262
pcl::VoxelGrid< pcl::PCLPointCloud2 >::setLeafSize
void setLeafSize(const Eigen::Vector4f &leaf_size)
Set the voxel grid leaf size.
Definition: voxel_grid.h:548
pcl::VoxelGrid::min_points_per_voxel_
unsigned int min_points_per_voxel_
Minimum number of points per voxel for the centroid to be computed.
Definition: voxel_grid.h:486
pcl::VoxelGrid< pcl::PCLPointCloud2 >::filter_limit_min_
double filter_limit_min_
The minimum allowed filter value a point will be considered from.
Definition: voxel_grid.h:831
PCL_EXPORTS
#define PCL_EXPORTS
Definition: pcl_macros.h:253
pcl::VoxelGrid< pcl::PCLPointCloud2 >::getCentroidIndex
int getCentroidIndex(float x, float y, float z) const
Returns the index in the resulting downsampled cloud of the specified point.
Definition: voxel_grid.h:643
pcl::shared_ptr
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: pcl_macros.h:90
pcl::traits::fieldList
Definition: point_traits.h:179
pcl::VoxelGrid::getLeafSize
Eigen::Vector3f getLeafSize() const
Get the voxel grid leaf size.
Definition: voxel_grid.h:250