Point Cloud Library (PCL)  1.8.1-dev
voxel_grid.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id$
37  *
38  */
39 
40 #ifndef PCL_FILTERS_VOXEL_GRID_MAP_H_
41 #define PCL_FILTERS_VOXEL_GRID_MAP_H_
42 
43 #include <pcl/filters/boost.h>
44 #include <pcl/filters/filter.h>
45 #include <map>
46 
47 namespace pcl
48 {
49  /** \brief Obtain the maximum and minimum points in 3D from a given point cloud.
50  * \param[in] cloud the pointer to a pcl::PCLPointCloud2 dataset
51  * \param[in] x_idx the index of the X channel
52  * \param[in] y_idx the index of the Y channel
53  * \param[in] z_idx the index of the Z channel
54  * \param[out] min_pt the minimum data point
55  * \param[out] max_pt the maximum data point
56  */
57  PCL_EXPORTS void
58  getMinMax3D (const pcl::PCLPointCloud2ConstPtr &cloud, int x_idx, int y_idx, int z_idx,
59  Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt);
60 
61  /** \brief Obtain the maximum and minimum points in 3D from a given point cloud.
62  * \note Performs internal data filtering as well.
63  * \param[in] cloud the pointer to a pcl::PCLPointCloud2 dataset
64  * \param[in] x_idx the index of the X channel
65  * \param[in] y_idx the index of the Y channel
66  * \param[in] z_idx the index of the Z channel
67  * \param[in] distance_field_name the name of the dimension to filter data along to
68  * \param[in] min_distance the minimum acceptable value in \a distance_field_name data
69  * \param[in] max_distance the maximum acceptable value in \a distance_field_name data
70  * \param[out] min_pt the minimum data point
71  * \param[out] max_pt the maximum data point
72  * \param[in] limit_negative \b false if data \b inside of the [min_distance; max_distance] interval should be
73  * considered, \b true otherwise.
74  */
75  PCL_EXPORTS void
76  getMinMax3D (const pcl::PCLPointCloud2ConstPtr &cloud, int x_idx, int y_idx, int z_idx,
77  const std::string &distance_field_name, float min_distance, float max_distance,
78  Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt, bool limit_negative = false);
79 
80  /** \brief Get the relative cell indices of the "upper half" 13 neighbors.
81  * \note Useful in combination with getNeighborCentroidIndices() from \ref VoxelGrid
82  * \ingroup filters
83  */
84  inline Eigen::MatrixXi
86  {
87  Eigen::MatrixXi relative_coordinates (3, 13);
88  int idx = 0;
89 
90  // 0 - 8
91  for (int i = -1; i < 2; i++)
92  {
93  for (int j = -1; j < 2; j++)
94  {
95  relative_coordinates (0, idx) = i;
96  relative_coordinates (1, idx) = j;
97  relative_coordinates (2, idx) = -1;
98  idx++;
99  }
100  }
101  // 9 - 11
102  for (int i = -1; i < 2; i++)
103  {
104  relative_coordinates (0, idx) = i;
105  relative_coordinates (1, idx) = -1;
106  relative_coordinates (2, idx) = 0;
107  idx++;
108  }
109  // 12
110  relative_coordinates (0, idx) = -1;
111  relative_coordinates (1, idx) = 0;
112  relative_coordinates (2, idx) = 0;
113 
114  return (relative_coordinates);
115  }
116 
117  /** \brief Get the relative cell indices of all the 26 neighbors.
118  * \note Useful in combination with getNeighborCentroidIndices() from \ref VoxelGrid
119  * \ingroup filters
120  */
121  inline Eigen::MatrixXi
123  {
124  Eigen::MatrixXi relative_coordinates = getHalfNeighborCellIndices ();
125  Eigen::MatrixXi relative_coordinates_all( 3, 26);
126  relative_coordinates_all.block<3, 13> (0, 0) = relative_coordinates;
127  relative_coordinates_all.block<3, 13> (0, 13) = -relative_coordinates;
128  return (relative_coordinates_all);
129  }
130 
131  /** \brief Get the minimum and maximum values on each of the 3 (x-y-z) dimensions
132  * in a given pointcloud, without considering points outside of a distance threshold from the laser origin
133  * \param[in] cloud the point cloud data message
134  * \param[in] distance_field_name the field name that contains the distance values
135  * \param[in] min_distance the minimum distance a point will be considered from
136  * \param[in] max_distance the maximum distance a point will be considered to
137  * \param[out] min_pt the resultant minimum bounds
138  * \param[out] max_pt the resultant maximum bounds
139  * \param[in] limit_negative if set to true, then all points outside of the interval (min_distance;max_distace) are considered
140  * \ingroup filters
141  */
142  template <typename PointT> void
143  getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
144  const std::string &distance_field_name, float min_distance, float max_distance,
145  Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt, bool limit_negative = false);
146 
147  /** \brief Get the minimum and maximum values on each of the 3 (x-y-z) dimensions
148  * in a given pointcloud, without considering points outside of a distance threshold from the laser origin
149  * \param[in] cloud the point cloud data message
150  * \param[in] indices the vector of indices to use
151  * \param[in] distance_field_name the field name that contains the distance values
152  * \param[in] min_distance the minimum distance a point will be considered from
153  * \param[in] max_distance the maximum distance a point will be considered to
154  * \param[out] min_pt the resultant minimum bounds
155  * \param[out] max_pt the resultant maximum bounds
156  * \param[in] limit_negative if set to true, then all points outside of the interval (min_distance;max_distace) are considered
157  * \ingroup filters
158  */
159  template <typename PointT> void
160  getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
161  const std::vector<int> &indices,
162  const std::string &distance_field_name, float min_distance, float max_distance,
163  Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt, bool limit_negative = false);
164 
165  /** \brief VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
166  *
167  * The VoxelGrid class creates a *3D voxel grid* (think about a voxel
168  * grid as a set of tiny 3D boxes in space) over the input point cloud data.
169  * Then, in each *voxel* (i.e., 3D box), all the points present will be
170  * approximated (i.e., *downsampled*) with their centroid. This approach is
171  * a bit slower than approximating them with the center of the voxel, but it
172  * represents the underlying surface more accurately.
173  *
174  * \author Radu B. Rusu, Bastian Steder
175  * \ingroup filters
176  */
177  template <typename PointT>
178  class VoxelGrid: public Filter<PointT>
179  {
180  protected:
185 
187  typedef typename PointCloud::Ptr PointCloudPtr;
189 
190  public:
191 
192  typedef boost::shared_ptr< VoxelGrid<PointT> > Ptr;
193  typedef boost::shared_ptr< const VoxelGrid<PointT> > ConstPtr;
194 
195  /** \brief Empty constructor. */
196  VoxelGrid () :
197  leaf_size_ (Eigen::Vector4f::Zero ()),
198  inverse_leaf_size_ (Eigen::Array4f::Zero ()),
199  downsample_all_data_ (true),
200  save_leaf_layout_ (false),
201  leaf_layout_ (),
202  min_b_ (Eigen::Vector4i::Zero ()),
203  max_b_ (Eigen::Vector4i::Zero ()),
204  div_b_ (Eigen::Vector4i::Zero ()),
205  divb_mul_ (Eigen::Vector4i::Zero ()),
206  filter_field_name_ (""),
207  filter_limit_min_ (-FLT_MAX),
208  filter_limit_max_ (FLT_MAX),
209  filter_limit_negative_ (false),
211  {
212  filter_name_ = "VoxelGrid";
213  }
214 
215  /** \brief Destructor. */
216  virtual ~VoxelGrid ()
217  {
218  }
219 
220  /** \brief Set the voxel grid leaf size.
221  * \param[in] leaf_size the voxel grid leaf size
222  */
223  inline void
224  setLeafSize (const Eigen::Vector4f &leaf_size)
225  {
226  leaf_size_ = leaf_size;
227  // Avoid division errors
228  if (leaf_size_[3] == 0)
229  leaf_size_[3] = 1;
230  // Use multiplications instead of divisions
231  inverse_leaf_size_ = Eigen::Array4f::Ones () / leaf_size_.array ();
232  }
233 
234  /** \brief Set the voxel grid leaf size.
235  * \param[in] lx the leaf size for X
236  * \param[in] ly the leaf size for Y
237  * \param[in] lz the leaf size for Z
238  */
239  inline void
240  setLeafSize (float lx, float ly, float lz)
241  {
242  leaf_size_[0] = lx; leaf_size_[1] = ly; leaf_size_[2] = lz;
243  // Avoid division errors
244  if (leaf_size_[3] == 0)
245  leaf_size_[3] = 1;
246  // Use multiplications instead of divisions
247  inverse_leaf_size_ = Eigen::Array4f::Ones () / leaf_size_.array ();
248  }
249 
250  /** \brief Get the voxel grid leaf size. */
251  inline Eigen::Vector3f
252  getLeafSize () { return (leaf_size_.head<3> ()); }
253 
254  /** \brief Set to true if all fields need to be downsampled, or false if just XYZ.
255  * \param[in] downsample the new value (true/false)
256  */
257  inline void
258  setDownsampleAllData (bool downsample) { downsample_all_data_ = downsample; }
259 
260  /** \brief Get the state of the internal downsampling parameter (true if
261  * all fields need to be downsampled, false if just XYZ).
262  */
263  inline bool
265 
266  /** \brief Set the minimum number of points required for a voxel to be used.
267  * \param[in] min_points_per_voxel the minimum number of points for required for a voxel to be used
268  */
269  inline void
270  setMinimumPointsNumberPerVoxel (unsigned int min_points_per_voxel) { min_points_per_voxel_ = min_points_per_voxel; }
271 
272  /** \brief Return the minimum number of points required for a voxel to be used.
273  */
274  inline unsigned int
276 
277  /** \brief Set to true if leaf layout information needs to be saved for later access.
278  * \param[in] save_leaf_layout the new value (true/false)
279  */
280  inline void
281  setSaveLeafLayout (bool save_leaf_layout) { save_leaf_layout_ = save_leaf_layout; }
282 
283  /** \brief Returns true if leaf layout information will to be saved for later access. */
284  inline bool
286 
287  /** \brief Get the minimum coordinates of the bounding box (after
288  * filtering is performed).
289  */
290  inline Eigen::Vector3i
291  getMinBoxCoordinates () { return (min_b_.head<3> ()); }
292 
293  /** \brief Get the minimum coordinates of the bounding box (after
294  * filtering is performed).
295  */
296  inline Eigen::Vector3i
297  getMaxBoxCoordinates () { return (max_b_.head<3> ()); }
298 
299  /** \brief Get the number of divisions along all 3 axes (after filtering
300  * is performed).
301  */
302  inline Eigen::Vector3i
303  getNrDivisions () { return (div_b_.head<3> ()); }
304 
305  /** \brief Get the multipliers to be applied to the grid coordinates in
306  * order to find the centroid index (after filtering is performed).
307  */
308  inline Eigen::Vector3i
309  getDivisionMultiplier () { return (divb_mul_.head<3> ()); }
310 
311  /** \brief Returns the index in the resulting downsampled cloud of the specified point.
312  *
313  * \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering
314  * performed, and that the point is inside the grid, to avoid invalid access (or use
315  * getGridCoordinates+getCentroidIndexAt)
316  *
317  * \param[in] p the point to get the index at
318  */
319  inline int
321  {
322  return (leaf_layout_.at ((Eigen::Vector4i (static_cast<int> (floor (p.x * inverse_leaf_size_[0])),
323  static_cast<int> (floor (p.y * inverse_leaf_size_[1])),
324  static_cast<int> (floor (p.z * inverse_leaf_size_[2])), 0) - min_b_).dot (divb_mul_)));
325  }
326 
327  /** \brief Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinates,
328  * relative to the grid coordinates of the specified point (or -1 if the cell was empty/out of bounds).
329  * \param[in] reference_point the coordinates of the reference point (corresponding cell is allowed to be empty/out of bounds)
330  * \param[in] relative_coordinates matrix with the columns being the coordinates of the requested cells, relative to the reference point's cell
331  * \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering performed
332  */
333  inline std::vector<int>
334  getNeighborCentroidIndices (const PointT &reference_point, const Eigen::MatrixXi &relative_coordinates)
335  {
336  Eigen::Vector4i ijk (static_cast<int> (floor (reference_point.x * inverse_leaf_size_[0])),
337  static_cast<int> (floor (reference_point.y * inverse_leaf_size_[1])),
338  static_cast<int> (floor (reference_point.z * inverse_leaf_size_[2])), 0);
339  Eigen::Array4i diff2min = min_b_ - ijk;
340  Eigen::Array4i diff2max = max_b_ - ijk;
341  std::vector<int> neighbors (relative_coordinates.cols());
342  for (int ni = 0; ni < relative_coordinates.cols (); ni++)
343  {
344  Eigen::Vector4i displacement = (Eigen::Vector4i() << relative_coordinates.col(ni), 0).finished();
345  // checking if the specified cell is in the grid
346  if ((diff2min <= displacement.array()).all() && (diff2max >= displacement.array()).all())
347  neighbors[ni] = leaf_layout_[((ijk + displacement - min_b_).dot (divb_mul_))]; // .at() can be omitted
348  else
349  neighbors[ni] = -1; // cell is out of bounds, consider it empty
350  }
351  return (neighbors);
352  }
353 
354  /** \brief Returns the layout of the leafs for fast access to cells relative to current position.
355  * \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)
356  */
357  inline std::vector<int>
358  getLeafLayout () { return (leaf_layout_); }
359 
360  /** \brief Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
361  * \param[in] x the X point coordinate to get the (i, j, k) index at
362  * \param[in] y the Y point coordinate to get the (i, j, k) index at
363  * \param[in] z the Z point coordinate to get the (i, j, k) index at
364  */
365  inline Eigen::Vector3i
366  getGridCoordinates (float x, float y, float z)
367  {
368  return (Eigen::Vector3i (static_cast<int> (floor (x * inverse_leaf_size_[0])),
369  static_cast<int> (floor (y * inverse_leaf_size_[1])),
370  static_cast<int> (floor (z * inverse_leaf_size_[2]))));
371  }
372 
373  /** \brief Returns the index in the downsampled cloud corresponding to a given set of coordinates.
374  * \param[in] ijk the coordinates (i,j,k) in the grid (-1 if empty)
375  */
376  inline int
377  getCentroidIndexAt (const Eigen::Vector3i &ijk)
378  {
379  int idx = ((Eigen::Vector4i() << ijk, 0).finished() - min_b_).dot (divb_mul_);
380  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
381  {
382  //if (verbose)
383  // 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 ());
384  return (-1);
385  }
386  return (leaf_layout_[idx]);
387  }
388 
389  /** \brief Provide the name of the field to be used for filtering data. In conjunction with \a setFilterLimits,
390  * points having values outside this interval will be discarded.
391  * \param[in] field_name the name of the field that contains values used for filtering
392  */
393  inline void
394  setFilterFieldName (const std::string &field_name)
395  {
396  filter_field_name_ = field_name;
397  }
398 
399  /** \brief Get the name of the field used for filtering. */
400  inline std::string const
402  {
403  return (filter_field_name_);
404  }
405 
406  /** \brief Set the field filter limits. All points having field values outside this interval will be discarded.
407  * \param[in] limit_min the minimum allowed field value
408  * \param[in] limit_max the maximum allowed field value
409  */
410  inline void
411  setFilterLimits (const double &limit_min, const double &limit_max)
412  {
413  filter_limit_min_ = limit_min;
414  filter_limit_max_ = limit_max;
415  }
416 
417  /** \brief Get the field filter limits (min/max) set by the user. The default values are -FLT_MAX, FLT_MAX.
418  * \param[out] limit_min the minimum allowed field value
419  * \param[out] limit_max the maximum allowed field value
420  */
421  inline void
422  getFilterLimits (double &limit_min, double &limit_max)
423  {
424  limit_min = filter_limit_min_;
425  limit_max = filter_limit_max_;
426  }
427 
428  /** \brief Set to true if we want to return the data outside the interval specified by setFilterLimits (min, max).
429  * Default: false.
430  * \param[in] limit_negative return data inside the interval (false) or outside (true)
431  */
432  inline void
433  setFilterLimitsNegative (const bool limit_negative)
434  {
435  filter_limit_negative_ = limit_negative;
436  }
437 
438  /** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
439  * \param[out] limit_negative true if data \b outside the interval [min; max] is to be returned, false otherwise
440  */
441  inline void
442  getFilterLimitsNegative (bool &limit_negative)
443  {
444  limit_negative = filter_limit_negative_;
445  }
446 
447  /** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
448  * \return true if data \b outside the interval [min; max] is to be returned, false otherwise
449  */
450  inline bool
452  {
453  return (filter_limit_negative_);
454  }
455 
456  protected:
457  /** \brief The size of a leaf. */
458  Eigen::Vector4f leaf_size_;
459 
460  /** \brief Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons. */
461  Eigen::Array4f inverse_leaf_size_;
462 
463  /** \brief Set to true if all fields need to be downsampled, or false if just XYZ. */
465 
466  /** \brief Set to true if leaf layout information needs to be saved in \a leaf_layout_. */
468 
469  /** \brief The leaf layout information for fast access to cells relative to current position **/
470  std::vector<int> leaf_layout_;
471 
472  /** \brief The minimum and maximum bin coordinates, the number of divisions, and the division multiplier. */
473  Eigen::Vector4i min_b_, max_b_, div_b_, divb_mul_;
474 
475  /** \brief The desired user filter field name. */
476  std::string filter_field_name_;
477 
478  /** \brief The minimum allowed filter value a point will be considered from. */
480 
481  /** \brief The maximum allowed filter value a point will be considered from. */
483 
484  /** \brief Set to true if we want to return the data outside (\a filter_limit_min_;\a filter_limit_max_). Default: false. */
486 
487  /** \brief Minimum number of points per voxel for the centroid to be computed */
488  unsigned int min_points_per_voxel_;
489 
491 
492  /** \brief Downsample a Point Cloud using a voxelized grid approach
493  * \param[out] output the resultant point cloud message
494  */
495  void
496  applyFilter (PointCloud &output);
497  };
498 
499  /** \brief VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
500  *
501  * The VoxelGrid class creates a *3D voxel grid* (think about a voxel
502  * grid as a set of tiny 3D boxes in space) over the input point cloud data.
503  * Then, in each *voxel* (i.e., 3D box), all the points present will be
504  * approximated (i.e., *downsampled*) with their centroid. This approach is
505  * a bit slower than approximating them with the center of the voxel, but it
506  * represents the underlying surface more accurately.
507  *
508  * \author Radu B. Rusu, Bastian Steder, Radoslaw Cybulski
509  * \ingroup filters
510  */
511  template <>
512  class PCL_EXPORTS VoxelGrid<pcl::PCLPointCloud2> : public Filter<pcl::PCLPointCloud2>
513  {
516 
520 
521  public:
522  /** \brief Empty constructor. */
523  VoxelGrid () :
524  leaf_size_ (Eigen::Vector4f::Zero ()),
525  inverse_leaf_size_ (Eigen::Array4f::Zero ()),
526  downsample_all_data_ (true),
527  save_leaf_layout_ (false),
528  leaf_layout_ (),
529  min_b_ (Eigen::Vector4i::Zero ()),
530  max_b_ (Eigen::Vector4i::Zero ()),
531  div_b_ (Eigen::Vector4i::Zero ()),
532  divb_mul_ (Eigen::Vector4i::Zero ()),
533  filter_field_name_ (""),
534  filter_limit_min_ (-FLT_MAX),
535  filter_limit_max_ (FLT_MAX),
536  filter_limit_negative_ (false),
537  min_points_per_voxel_ (0)
538  {
539  filter_name_ = "VoxelGrid";
540  }
541 
542  /** \brief Destructor. */
543  virtual ~VoxelGrid ()
544  {
545  }
546 
547  /** \brief Set the voxel grid leaf size.
548  * \param[in] leaf_size the voxel grid leaf size
549  */
550  inline void
551  setLeafSize (const Eigen::Vector4f &leaf_size)
552  {
553  leaf_size_ = leaf_size;
554  // Avoid division errors
555  if (leaf_size_[3] == 0)
556  leaf_size_[3] = 1;
557  // Use multiplications instead of divisions
558  inverse_leaf_size_ = Eigen::Array4f::Ones () / leaf_size_.array ();
559  }
560 
561  /** \brief Set the voxel grid leaf size.
562  * \param[in] lx the leaf size for X
563  * \param[in] ly the leaf size for Y
564  * \param[in] lz the leaf size for Z
565  */
566  inline void
567  setLeafSize (float lx, float ly, float lz)
568  {
569  leaf_size_[0] = lx; leaf_size_[1] = ly; leaf_size_[2] = lz;
570  // Avoid division errors
571  if (leaf_size_[3] == 0)
572  leaf_size_[3] = 1;
573  // Use multiplications instead of divisions
574  inverse_leaf_size_ = Eigen::Array4f::Ones () / leaf_size_.array ();
575  }
576 
577  /** \brief Get the voxel grid leaf size. */
578  inline Eigen::Vector3f
579  getLeafSize () { return (leaf_size_.head<3> ()); }
580 
581  /** \brief Set to true if all fields need to be downsampled, or false if just XYZ.
582  * \param[in] downsample the new value (true/false)
583  */
584  inline void
585  setDownsampleAllData (bool downsample) { downsample_all_data_ = downsample; }
586 
587  /** \brief Get the state of the internal downsampling parameter (true if
588  * all fields need to be downsampled, false if just XYZ).
589  */
590  inline bool
591  getDownsampleAllData () { return (downsample_all_data_); }
592 
593  /** \brief Set the minimum number of points required for a voxel to be used.
594  * \param[in] min_points_per_voxel the minimum number of points for required for a voxel to be used
595  */
596  inline void
597  setMinimumPointsNumberPerVoxel (unsigned int min_points_per_voxel) { min_points_per_voxel_ = min_points_per_voxel; }
598 
599  /** \brief Return the minimum number of points required for a voxel to be used.
600  */
601  inline unsigned int
602  getMinimumPointsNumberPerVoxel () { return min_points_per_voxel_; }
603 
604  /** \brief Set to true if leaf layout information needs to be saved for later access.
605  * \param[in] save_leaf_layout the new value (true/false)
606  */
607  inline void
608  setSaveLeafLayout (bool save_leaf_layout) { save_leaf_layout_ = save_leaf_layout; }
609 
610  /** \brief Returns true if leaf layout information will to be saved for later access. */
611  inline bool
612  getSaveLeafLayout () { return (save_leaf_layout_); }
613 
614  /** \brief Get the minimum coordinates of the bounding box (after
615  * filtering is performed).
616  */
617  inline Eigen::Vector3i
618  getMinBoxCoordinates () { return (min_b_.head<3> ()); }
619 
620  /** \brief Get the minimum coordinates of the bounding box (after
621  * filtering is performed).
622  */
623  inline Eigen::Vector3i
624  getMaxBoxCoordinates () { return (max_b_.head<3> ()); }
625 
626  /** \brief Get the number of divisions along all 3 axes (after filtering
627  * is performed).
628  */
629  inline Eigen::Vector3i
630  getNrDivisions () { return (div_b_.head<3> ()); }
631 
632  /** \brief Get the multipliers to be applied to the grid coordinates in
633  * order to find the centroid index (after filtering is performed).
634  */
635  inline Eigen::Vector3i
636  getDivisionMultiplier () { return (divb_mul_.head<3> ()); }
637 
638  /** \brief Returns the index in the resulting downsampled cloud of the specified point.
639  * \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering performed,
640  * and that the point is inside the grid, to avoid invalid access (or use getGridCoordinates+getCentroidIndexAt)
641  * \param[in] x the X point coordinate to get the index at
642  * \param[in] y the Y point coordinate to get the index at
643  * \param[in] z the Z point coordinate to get the index at
644  */
645  inline int
646  getCentroidIndex (float x, float y, float z)
647  {
648  return (leaf_layout_.at ((Eigen::Vector4i (static_cast<int> (floor (x * inverse_leaf_size_[0])),
649  static_cast<int> (floor (y * inverse_leaf_size_[1])),
650  static_cast<int> (floor (z * inverse_leaf_size_[2])),
651  0)
652  - min_b_).dot (divb_mul_)));
653  }
654 
655  /** \brief Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinates,
656  * relative to the grid coordinates of the specified point (or -1 if the cell was empty/out of bounds).
657  * \param[in] x the X coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
658  * \param[in] y the Y coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
659  * \param[in] z the Z coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
660  * \param[out] relative_coordinates matrix with the columns being the coordinates of the requested cells, relative to the reference point's cell
661  * \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering performed
662  */
663  inline std::vector<int>
664  getNeighborCentroidIndices (float x, float y, float z, const Eigen::MatrixXi &relative_coordinates)
665  {
666  Eigen::Vector4i ijk (static_cast<int> (floor (x * inverse_leaf_size_[0])),
667  static_cast<int> (floor (y * inverse_leaf_size_[1])),
668  static_cast<int> (floor (z * inverse_leaf_size_[2])), 0);
669  Eigen::Array4i diff2min = min_b_ - ijk;
670  Eigen::Array4i diff2max = max_b_ - ijk;
671  std::vector<int> neighbors (relative_coordinates.cols());
672  for (int ni = 0; ni < relative_coordinates.cols (); ni++)
673  {
674  Eigen::Vector4i displacement = (Eigen::Vector4i() << relative_coordinates.col(ni), 0).finished();
675  // checking if the specified cell is in the grid
676  if ((diff2min <= displacement.array()).all() && (diff2max >= displacement.array()).all())
677  neighbors[ni] = leaf_layout_[((ijk + displacement - min_b_).dot (divb_mul_))]; // .at() can be omitted
678  else
679  neighbors[ni] = -1; // cell is out of bounds, consider it empty
680  }
681  return (neighbors);
682  }
683 
684  /** \brief Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinates,
685  * relative to the grid coordinates of the specified point (or -1 if the cell was empty/out of bounds).
686  * \param[in] x the X coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
687  * \param[in] y the Y coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
688  * \param[in] z the Z coordinate of the reference point (corresponding cell is allowed to be empty/out of bounds)
689  * \param[out] relative_coordinates vector with the elements being the coordinates of the requested cells, relative to the reference point's cell
690  * \note for efficiency, user must make sure that the saving of the leaf layout is enabled and filtering performed
691  */
692  inline std::vector<int>
693  getNeighborCentroidIndices (float x, float y, float z, const std::vector<Eigen::Vector3i, Eigen::aligned_allocator<Eigen::Vector3i> > &relative_coordinates)
694  {
695  Eigen::Vector4i ijk (static_cast<int> (floorf (x * inverse_leaf_size_[0])), static_cast<int> (floorf (y * inverse_leaf_size_[1])), static_cast<int> (floorf (z * inverse_leaf_size_[2])), 0);
696  std::vector<int> neighbors;
697  neighbors.reserve (relative_coordinates.size ());
698  for (std::vector<Eigen::Vector3i, Eigen::aligned_allocator<Eigen::Vector3i> >::const_iterator it = relative_coordinates.begin (); it != relative_coordinates.end (); it++)
699  neighbors.push_back (leaf_layout_[(ijk + (Eigen::Vector4i() << *it, 0).finished() - min_b_).dot (divb_mul_)]);
700  return (neighbors);
701  }
702 
703  /** \brief Returns the layout of the leafs for fast access to cells relative to current position.
704  * \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)
705  */
706  inline std::vector<int>
707  getLeafLayout () { return (leaf_layout_); }
708 
709  /** \brief Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
710  * \param[in] x the X point coordinate to get the (i, j, k) index at
711  * \param[in] y the Y point coordinate to get the (i, j, k) index at
712  * \param[in] z the Z point coordinate to get the (i, j, k) index at
713  */
714  inline Eigen::Vector3i
715  getGridCoordinates (float x, float y, float z)
716  {
717  return (Eigen::Vector3i (static_cast<int> (floor (x * inverse_leaf_size_[0])),
718  static_cast<int> (floor (y * inverse_leaf_size_[1])),
719  static_cast<int> (floor (z * inverse_leaf_size_[2]))));
720  }
721 
722  /** \brief Returns the index in the downsampled cloud corresponding to a given set of coordinates.
723  * \param[in] ijk the coordinates (i,j,k) in the grid (-1 if empty)
724  */
725  inline int
726  getCentroidIndexAt (const Eigen::Vector3i &ijk)
727  {
728  int idx = ((Eigen::Vector4i() << ijk, 0).finished() - min_b_).dot (divb_mul_);
729  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
730  {
731  //if (verbose)
732  // 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 ());
733  return (-1);
734  }
735  return (leaf_layout_[idx]);
736  }
737 
738  /** \brief Provide the name of the field to be used for filtering data. In conjunction with \a setFilterLimits,
739  * points having values outside this interval will be discarded.
740  * \param[in] field_name the name of the field that contains values used for filtering
741  */
742  inline void
743  setFilterFieldName (const std::string &field_name)
744  {
745  filter_field_name_ = field_name;
746  }
747 
748  /** \brief Get the name of the field used for filtering. */
749  inline std::string const
751  {
752  return (filter_field_name_);
753  }
754 
755  /** \brief Set the field filter limits. All points having field values outside this interval will be discarded.
756  * \param[in] limit_min the minimum allowed field value
757  * \param[in] limit_max the maximum allowed field value
758  */
759  inline void
760  setFilterLimits (const double &limit_min, const double &limit_max)
761  {
762  filter_limit_min_ = limit_min;
763  filter_limit_max_ = limit_max;
764  }
765 
766  /** \brief Get the field filter limits (min/max) set by the user. The default values are -FLT_MAX, FLT_MAX.
767  * \param[out] limit_min the minimum allowed field value
768  * \param[out] limit_max the maximum allowed field value
769  */
770  inline void
771  getFilterLimits (double &limit_min, double &limit_max)
772  {
773  limit_min = filter_limit_min_;
774  limit_max = filter_limit_max_;
775  }
776 
777  /** \brief Set to true if we want to return the data outside the interval specified by setFilterLimits (min, max).
778  * Default: false.
779  * \param[in] limit_negative return data inside the interval (false) or outside (true)
780  */
781  inline void
782  setFilterLimitsNegative (const bool limit_negative)
783  {
784  filter_limit_negative_ = limit_negative;
785  }
786 
787  /** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
788  * \param[out] limit_negative true if data \b outside the interval [min; max] is to be returned, false otherwise
789  */
790  inline void
791  getFilterLimitsNegative (bool &limit_negative)
792  {
793  limit_negative = filter_limit_negative_;
794  }
795 
796  /** \brief Get whether the data outside the interval (min/max) is to be returned (true) or inside (false).
797  * \return true if data \b outside the interval [min; max] is to be returned, false otherwise
798  */
799  inline bool
801  {
802  return (filter_limit_negative_);
803  }
804 
805  protected:
806  /** \brief The size of a leaf. */
807  Eigen::Vector4f leaf_size_;
808 
809  /** \brief Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons. */
810  Eigen::Array4f inverse_leaf_size_;
811 
812  /** \brief Set to true if all fields need to be downsampled, or false if just XYZ. */
814 
815  /** \brief Set to true if leaf layout information needs to be saved in \a
816  * leaf_layout.
817  */
819 
820  /** \brief The leaf layout information for fast access to cells relative
821  * to current position
822  */
823  std::vector<int> leaf_layout_;
824 
825  /** \brief The minimum and maximum bin coordinates, the number of
826  * divisions, and the division multiplier.
827  */
828  Eigen::Vector4i min_b_, max_b_, div_b_, divb_mul_;
829 
830  /** \brief The desired user filter field name. */
831  std::string filter_field_name_;
832 
833  /** \brief The minimum allowed filter value a point will be considered from. */
835 
836  /** \brief The maximum allowed filter value a point will be considered from. */
838 
839  /** \brief Set to true if we want to return the data outside (\a filter_limit_min_;\a filter_limit_max_). Default: false. */
841 
842  /** \brief Minimum number of points per voxel for the centroid to be computed */
843  unsigned int min_points_per_voxel_;
844 
845  /** \brief Downsample a Point Cloud using a voxelized grid approach
846  * \param[out] output the resultant point cloud
847  */
848  void
849  applyFilter (PCLPointCloud2 &output);
850  };
851 }
852 
853 #ifdef PCL_NO_PRECOMPILE
854 #include <pcl/filters/impl/voxel_grid.hpp>
855 #endif
856 
857 #endif //#ifndef PCL_FILTERS_VOXEL_GRID_MAP_H_
PointCloud::Ptr PointCloudPtr
Definition: voxel_grid.h:187
unsigned int min_points_per_voxel_
Minimum number of points per voxel for the centroid to be computed.
Definition: voxel_grid.h:488
std::vector< int > getNeighborCentroidIndices(float x, float y, float z, const std::vector< Eigen::Vector3i, Eigen::aligned_allocator< Eigen::Vector3i > > &relative_coordinates)
Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinate...
Definition: voxel_grid.h:693
Eigen::Vector3i getGridCoordinates(float x, float y, float z)
Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
Definition: voxel_grid.h:715
void applyFilter(PointCloud &output)
Downsample a Point Cloud using a voxelized grid approach.
Definition: voxel_grid.hpp:214
Eigen::Vector3f getLeafSize()
Get the voxel grid leaf size.
Definition: voxel_grid.h:252
bool getDownsampleAllData()
Get the state of the internal downsampling parameter (true if all fields need to be downsampled...
Definition: voxel_grid.h:264
void setLeafSize(const Eigen::Vector4f &leaf_size)
Set the voxel grid leaf size.
Definition: voxel_grid.h:551
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
void setFilterFieldName(const std::string &field_name)
Provide the name of the field to be used for filtering data.
Definition: voxel_grid.h:394
void getFilterLimitsNegative(bool &limit_negative)
Get whether the data outside the interval (min/max) is to be returned (true) or inside (false)...
Definition: voxel_grid.h:791
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:433
bool downsample_all_data_
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:813
std::vector< int > getNeighborCentroidIndices(float x, float y, float z, const Eigen::MatrixXi &relative_coordinates)
Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinate...
Definition: voxel_grid.h:664
Eigen::Vector3i getMaxBoxCoordinates()
Get the minimum coordinates of the bounding box (after filtering is performed).
Definition: voxel_grid.h:624
std::vector< int > leaf_layout_
The leaf layout information for fast access to cells relative to current position.
Definition: voxel_grid.h:823
unsigned int min_points_per_voxel_
Minimum number of points per voxel for the centroid to be computed.
Definition: voxel_grid.h:843
bool downsample_all_data_
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:464
Eigen::Vector3i getNrDivisions()
Get the number of divisions along all 3 axes (after filtering is performed).
Definition: voxel_grid.h:303
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
bool getDownsampleAllData()
Get the state of the internal downsampling parameter (true if all fields need to be downsampled...
Definition: voxel_grid.h:591
bool getFilterLimitsNegative()
Get whether the data outside the interval (min/max) is to be returned (true) or inside (false)...
Definition: voxel_grid.h:451
void setFilterFieldName(const std::string &field_name)
Provide the name of the field to be used for filtering data.
Definition: voxel_grid.h:743
void setFilterLimits(const double &limit_min, const double &limit_max)
Set the field filter limits.
Definition: voxel_grid.h:411
Eigen::Vector4i max_b_
Definition: voxel_grid.h:473
Eigen::Vector4f leaf_size_
The size of a leaf.
Definition: voxel_grid.h:807
boost::shared_ptr< VoxelGrid< PointT > > Ptr
Definition: voxel_grid.h:192
pcl::traits::fieldList< PointT >::type FieldList
Definition: voxel_grid.h:490
Eigen::Vector4i min_b_
The minimum and maximum bin coordinates, the number of divisions, and the division multiplier...
Definition: voxel_grid.h:828
boost::shared_ptr< ::pcl::PCLPointCloud2 const > PCLPointCloud2ConstPtr
void setDownsampleAllData(bool downsample)
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:258
void getFilterLimits(double &limit_min, double &limit_max)
Get the field filter limits (min/max) set by the user.
Definition: voxel_grid.h:771
void setSaveLeafLayout(bool save_leaf_layout)
Set to true if leaf layout information needs to be saved for later access.
Definition: voxel_grid.h:281
std::vector< int > getNeighborCentroidIndices(const PointT &reference_point, const Eigen::MatrixXi &relative_coordinates)
Returns the indices in the resulting downsampled cloud of the points at the specified grid coordinate...
Definition: voxel_grid.h:334
Eigen::Vector3i getNrDivisions()
Get the number of divisions along all 3 axes (after filtering is performed).
Definition: voxel_grid.h:630
VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data...
Definition: voxel_grid.h:178
std::vector< int > getLeafLayout()
Returns the layout of the leafs for fast access to cells relative to current position.
Definition: voxel_grid.h:707
void setLeafSize(float lx, float ly, float lz)
Set the voxel grid leaf size.
Definition: voxel_grid.h:240
bool getSaveLeafLayout()
Returns true if leaf layout information will to be saved for later access.
Definition: voxel_grid.h:612
Eigen::Vector3i getDivisionMultiplier()
Get the multipliers to be applied to the grid coordinates in order to find the centroid index (after ...
Definition: voxel_grid.h:309
boost::shared_ptr< ::pcl::PCLPointCloud2 > Ptr
std::string filter_field_name_
The desired user filter field name.
Definition: voxel_grid.h:831
std::string const getFilterFieldName()
Get the name of the field used for filtering.
Definition: voxel_grid.h:750
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:840
Eigen::Vector3i getDivisionMultiplier()
Get the multipliers to be applied to the grid coordinates in order to find the centroid index (after ...
Definition: voxel_grid.h:636
unsigned int getMinimumPointsNumberPerVoxel()
Return the minimum number of points required for a voxel to be used.
Definition: voxel_grid.h:275
virtual ~VoxelGrid()
Destructor.
Definition: voxel_grid.h:216
std::string const getFilterFieldName()
Get the name of the field used for filtering.
Definition: voxel_grid.h:401
int getCentroidIndex(float x, float y, float z)
Returns the index in the resulting downsampled cloud of the specified point.
Definition: voxel_grid.h:646
Eigen::Array4f inverse_leaf_size_
Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons.
Definition: voxel_grid.h:810
Eigen::Vector3i getMinBoxCoordinates()
Get the minimum coordinates of the bounding box (after filtering is performed).
Definition: voxel_grid.h:291
Eigen::Vector3i getMinBoxCoordinates()
Get the minimum coordinates of the bounding box (after filtering is performed).
Definition: voxel_grid.h:618
Filter represents the base filter class.
Definition: filter.h:84
void setLeafSize(float lx, float ly, float lz)
Set the voxel grid leaf size.
Definition: voxel_grid.h:567
int getCentroidIndexAt(const Eigen::Vector3i &ijk)
Returns the index in the downsampled cloud corresponding to a given set of coordinates.
Definition: voxel_grid.h:726
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:270
Eigen::Array4f inverse_leaf_size_
Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons.
Definition: voxel_grid.h:461
std::vector< int > getLeafLayout()
Returns the layout of the leafs for fast access to cells relative to current position.
Definition: voxel_grid.h:358
Eigen::Vector3i getGridCoordinates(float x, float y, float z)
Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
Definition: voxel_grid.h:366
int getCentroidIndex(const PointT &p)
Returns the index in the resulting downsampled cloud of the specified point.
Definition: voxel_grid.h:320
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:228
Eigen::MatrixXi getHalfNeighborCellIndices()
Get the relative cell indices of the "upper half" 13 neighbors.
Definition: voxel_grid.h:85
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:782
void setSaveLeafLayout(bool save_leaf_layout)
Set to true if leaf layout information needs to be saved for later access.
Definition: voxel_grid.h:608
void setDownsampleAllData(bool downsample)
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:585
boost::shared_ptr< ::pcl::PCLPointCloud2 const > ConstPtr
Eigen::Vector3i getMaxBoxCoordinates()
Get the minimum coordinates of the bounding box (after filtering is performed).
Definition: voxel_grid.h:297
void setFilterLimits(const double &limit_min, const double &limit_max)
Set the field filter limits.
Definition: voxel_grid.h:760
double filter_limit_max_
The maximum allowed filter value a point will be considered from.
Definition: voxel_grid.h:837
bool getFilterLimitsNegative()
Get whether the data outside the interval (min/max) is to be returned (true) or inside (false)...
Definition: voxel_grid.h:800
Eigen::Vector4i divb_mul_
Definition: voxel_grid.h:473
Eigen::Vector4f leaf_size_
The size of a leaf.
Definition: voxel_grid.h:458
boost::shared_ptr< ::pcl::PCLPointCloud2 > PCLPointCloud2Ptr
std::vector< int > leaf_layout_
The leaf layout information for fast access to cells relative to current position.
Definition: voxel_grid.h:470
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:597
std::string filter_field_name_
The desired user filter field name.
Definition: voxel_grid.h:476
VoxelGrid()
Empty constructor.
Definition: voxel_grid.h:196
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:485
void getFilterLimitsNegative(bool &limit_negative)
Get whether the data outside the interval (min/max) is to be returned (true) or inside (false)...
Definition: voxel_grid.h:442
bool save_leaf_layout_
Set to true if leaf layout information needs to be saved in leaf_layout.
Definition: voxel_grid.h:818
boost::shared_ptr< const VoxelGrid< PointT > > ConstPtr
Definition: voxel_grid.h:193
Eigen::MatrixXi getAllNeighborCellIndices()
Get the relative cell indices of all the 26 neighbors.
Definition: voxel_grid.h:122
double filter_limit_min_
The minimum allowed filter value a point will be considered from.
Definition: voxel_grid.h:834
double filter_limit_max_
The maximum allowed filter value a point will be considered from.
Definition: voxel_grid.h:482
PointCloud::ConstPtr PointCloudConstPtr
Definition: voxel_grid.h:188
std::string filter_name_
The filter name.
Definition: filter.h:166
Eigen::Vector4i min_b_
The minimum and maximum bin coordinates, the number of divisions, and the division multiplier...
Definition: voxel_grid.h:473
A point structure representing Euclidean xyz coordinates, and the RGB color.
bool save_leaf_layout_
Set to true if leaf layout information needs to be saved in leaf_layout_.
Definition: voxel_grid.h:467
double filter_limit_min_
The minimum allowed filter value a point will be considered from.
Definition: voxel_grid.h:479
int getCentroidIndexAt(const Eigen::Vector3i &ijk)
Returns the index in the downsampled cloud corresponding to a given set of coordinates.
Definition: voxel_grid.h:377
Eigen::Vector4i div_b_
Definition: voxel_grid.h:473
unsigned int getMinimumPointsNumberPerVoxel()
Return the minimum number of points required for a voxel to be used.
Definition: voxel_grid.h:602
virtual ~VoxelGrid()
Destructor.
Definition: voxel_grid.h:543
bool getSaveLeafLayout()
Returns true if leaf layout information will to be saved for later access.
Definition: voxel_grid.h:285
void setLeafSize(const Eigen::Vector4f &leaf_size)
Set the voxel grid leaf size.
Definition: voxel_grid.h:224
Filter< PointT >::PointCloud PointCloud
Definition: voxel_grid.h:186
void getFilterLimits(double &limit_min, double &limit_max)
Get the field filter limits (min/max) set by the user.
Definition: voxel_grid.h:422
Eigen::Vector3f getLeafSize()
Get the voxel grid leaf size.
Definition: voxel_grid.h:579