Point Cloud Library (PCL)  1.8.0
height_map_2d.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2013-, Open Perception, 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  * height_map_2d.h
37  * Created on: Nov 30, 2012
38  * Author: Matteo Munaro
39  */
40 
41 #ifndef PCL_PEOPLE_HEIGHT_MAP_2D_H_
42 #define PCL_PEOPLE_HEIGHT_MAP_2D_H_
43 
44 #include <pcl/people/person_cluster.h>
45 #include <pcl/point_types.h>
46 
47 namespace pcl
48 {
49  namespace people
50  {
51  /** \brief @b HeightMap2D represents a class for creating a 2D height map from a point cloud and searching for its local maxima
52  * \author Matteo Munaro
53  * \ingroup people
54  */
55  template <typename PointT> class HeightMap2D;
56 
57  template <typename PointT>
58  class HeightMap2D
59  {
60  public:
61 
63  typedef boost::shared_ptr<PointCloud> PointCloudPtr;
64  typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr;
65 
66  /** \brief Constructor. */
67  HeightMap2D();
68 
69  /** \brief Destructor. */
70  virtual ~HeightMap2D ();
71 
72  /**
73  * \brief Compute the height map with the projection of cluster points onto the ground plane.
74  *
75  * \param[in] cluster The PersonCluster used to compute the height map.
76  */
77  void
79 
80  /**
81  * \brief Compute local maxima of the height map.
82  */
83  void
85 
86  /**
87  * \brief Filter maxima of the height map by imposing a minimum distance between them.
88  */
89  void
90  filterMaxima ();
91 
92  /**
93  * \brief Set initial cluster indices.
94  *
95  * \param[in] cloud A pointer to the input cloud.
96  */
97  void
98  setInputCloud (PointCloudPtr& cloud);
99 
100  /**
101  * \brief Set the ground coefficients.
102  *
103  * \param[in] ground_coeffs The ground plane coefficients.
104  */
105  void
106  setGround (Eigen::VectorXf& ground_coeffs);
107 
108  /**
109  * \brief Set bin size for the height map.
110  *
111  * \param[in] bin_size Bin size for the height map (default = 0.06).
112  */
113  void
114  setBinSize (float bin_size);
115 
116  /**
117  * \brief Set minimum distance between maxima.
118  *
119  * \param[in] minimum_distance_between_maxima Minimum allowed distance between maxima (default = 0.3).
120  */
121  void
122  setMinimumDistanceBetweenMaxima (float minimum_distance_between_maxima);
123 
124  /**
125  * \brief Set sensor orientation to landscape mode (false) or portrait mode (true).
126  *
127  * \param[in] vertical Landscape (false) or portrait (true) mode (default = false).
128  */
129  void
130  setSensorPortraitOrientation (bool vertical);
131 
132  /**
133  * \brief Get the height map as a vector of int.
134  */
135  std::vector<int>&
136  getHeightMap ();
137 
138  /**
139  * \brief Get bin size for the height map.
140  */
141  float
142  getBinSize ();
143 
144  /**
145  * \brief Get minimum distance between maxima of the height map.
146  */
147  float
149 
150  /**
151  * \brief Return the maxima number after the filterMaxima method.
152  */
153  int&
155 
156  /**
157  * \brief Return the point cloud indices corresponding to the maxima computed after the filterMaxima method.
158  */
159  std::vector<int>&
161 
162  protected:
163  /** \brief ground plane coefficients */
164  Eigen::VectorXf ground_coeffs_;
165 
166  /** \brief ground plane normalization factor */
168 
169  /** \brief pointer to the input cloud */
170  PointCloudPtr cloud_;
171 
172  /** \brief if true, the sensor is considered to be vertically placed (portrait mode) */
173  bool vertical_;
174 
175  /** \brief vector with maximum height values for every bin (height map) */
176  std::vector<int> buckets_;
177 
178  /** \brief indices of the pointcloud points with maximum height for every bin */
179  std::vector<int> buckets_cloud_indices_;
180 
181  /** \brief bin dimension */
182  float bin_size_;
183 
184  /** \brief number of local maxima in the height map */
186 
187  /** \brief contains the position of the maxima in the buckets vector */
188  std::vector<int> maxima_indices_;
189 
190  /** \brief contains the point cloud position of the maxima (indices of the point cloud) */
191  std::vector<int> maxima_cloud_indices_;
192 
193  /** \brief number of local maxima after filtering */
195 
196  /** \brief contains the position of the maxima in the buckets array after filtering */
197  std::vector<int> maxima_indices_filtered_;
198 
199  /** \brief contains the point cloud position of the maxima after filtering */
201 
202  /** \brief minimum allowed distance between maxima */
204  };
205 
206  } /* namespace people */
207 } /* namespace pcl */
208 #include <pcl/people/impl/height_map_2d.hpp>
209 #endif /* PCL_PEOPLE_HEIGHT_MAP_2D_H_ */
int & getMaximaNumberAfterFiltering()
Return the maxima number after the filterMaxima method.
Eigen::VectorXf ground_coeffs_
ground plane coefficients
pcl::PointCloud< PointT > PointCloud
Definition: height_map_2d.h:62
int maxima_number_
number of local maxima in the height map
HeightMap2D()
Constructor.
void compute(pcl::people::PersonCluster< PointT > &cluster)
Compute the height map with the projection of cluster points onto the ground plane.
virtual ~HeightMap2D()
Destructor.
void setBinSize(float bin_size)
Set bin size for the height map.
float getBinSize()
Get bin size for the height map.
float min_dist_between_maxima_
minimum allowed distance between maxima
float bin_size_
bin dimension
std::vector< int > buckets_
vector with maximum height values for every bin (height map)
std::vector< int > maxima_cloud_indices_filtered_
contains the point cloud position of the maxima after filtering
PersonCluster represents a class for representing information about a cluster containing a person...
std::vector< int > maxima_cloud_indices_
contains the point cloud position of the maxima (indices of the point cloud)
float sqrt_ground_coeffs_
ground plane normalization factor
void searchLocalMaxima()
Compute local maxima of the height map.
std::vector< int > maxima_indices_filtered_
contains the position of the maxima in the buckets array after filtering
void setGround(Eigen::VectorXf &ground_coeffs)
Set the ground coefficients.
boost::shared_ptr< PointCloud > PointCloudPtr
Definition: height_map_2d.h:63
std::vector< int > & getHeightMap()
Get the height map as a vector of int.
PointCloudPtr cloud_
pointer to the input cloud
boost::shared_ptr< const PointCloud > PointCloudConstPtr
Definition: height_map_2d.h:64
std::vector< int > & getMaximaCloudIndicesFiltered()
Return the point cloud indices corresponding to the maxima computed after the filterMaxima method...
std::vector< int > maxima_indices_
contains the position of the maxima in the buckets vector
float getMinimumDistanceBetweenMaxima()
Get minimum distance between maxima of the height map.
void setInputCloud(PointCloudPtr &cloud)
Set initial cluster indices.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
bool vertical_
if true, the sensor is considered to be vertically placed (portrait mode)
std::vector< int > buckets_cloud_indices_
indices of the pointcloud points with maximum height for every bin
void setMinimumDistanceBetweenMaxima(float minimum_distance_between_maxima)
Set minimum distance between maxima.
int maxima_number_after_filtering_
number of local maxima after filtering
void setSensorPortraitOrientation(bool vertical)
Set sensor orientation to landscape mode (false) or portrait mode (true).
HeightMap2D represents a class for creating a 2D height map from a point cloud and searching for its ...
Definition: height_map_2d.h:55
void filterMaxima()
Filter maxima of the height map by imposing a minimum distance between them.