Point Cloud Library (PCL)  1.7.1
head_based_subcluster.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  * head_based_subcluster.h
37  * Created on: Nov 30, 2012
38  * Author: Matteo Munaro
39  */
40 
41 #ifndef PCL_PEOPLE_HEAD_BASED_SUBCLUSTER_H_
42 #define PCL_PEOPLE_HEAD_BASED_SUBCLUSTER_H_
43 
44 #include <pcl/people/person_cluster.h>
45 #include <pcl/people/height_map_2d.h>
46 #include <pcl/point_types.h>
47 
48 namespace pcl
49 {
50  namespace people
51  {
52  /** \brief @b HeadBasedSubclustering represents a class for searching for people inside a HeightMap2D based on a 3D head detection algorithm
53  * \author Matteo Munaro
54  * \ingroup people
55  */
56  template <typename PointT> class HeadBasedSubclustering;
57 
58  template <typename PointT>
60  {
61  public:
62 
64  typedef boost::shared_ptr<PointCloud> PointCloudPtr;
65  typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr;
66 
67  /** \brief Constructor. */
69 
70  /** \brief Destructor. */
71  virtual ~HeadBasedSubclustering ();
72 
73  /**
74  * \brief Compute subclusters and return them into a vector of PersonCluster.
75  *
76  * \param[in] clusters Vector of PersonCluster.
77  */
78  void
79  subcluster (std::vector<pcl::people::PersonCluster<PointT> >& clusters);
80 
81  /**
82  * \brief Merge clusters close in floor coordinates.
83  *
84  * \param[in] input_clusters Input vector of PersonCluster.
85  * \param[in] output_clusters Output vector of PersonCluster (after merging).
86  */
87  void
89  std::vector<pcl::people::PersonCluster<PointT> >& output_clusters);
90 
91  /**
92  * \brief Create subclusters centered on the heads position from the current cluster.
93  *
94  * \param[in] cluster A PersonCluster.
95  * \param[in] maxima_number Number of local maxima to use as centers of the new cluster.
96  * \param[in] maxima_cloud_indices Cloud indices of local maxima to use as centers of the new cluster.
97  * \param[out] subclusters Output vector of PersonCluster objects derived from the input cluster.
98  */
99  void
100  createSubClusters (pcl::people::PersonCluster<PointT>& cluster, int maxima_number_after_filtering, std::vector<int>& maxima_cloud_indices_filtered,
101  std::vector<pcl::people::PersonCluster<PointT> >& subclusters);
102 
103  /**
104  * \brief Set input cloud.
105  *
106  * \param[in] cloud A pointer to the input point cloud.
107  */
108  void
109  setInputCloud (PointCloudPtr& cloud);
110 
111  /**
112  * \brief Set the ground coefficients.
113  *
114  * \param[in] ground_coeffs The ground plane coefficients.
115  */
116  void
117  setGround (Eigen::VectorXf& ground_coeffs);
118 
119  /**
120  * \brief Set sensor orientation to landscape mode (false) or portrait mode (true).
121  *
122  * \param[in] vertical Landscape (false) or portrait (true) mode (default = false).
123  */
124  void
125  setSensorPortraitOrientation (bool vertical);
126 
127  /**
128  * \brief Set head_centroid_ to true (person centroid is in the head) or false (person centroid is the whole body centroid).
129  *
130  * \param[in] head_centroid Set the location of the person centroid (head or body center) (default = true).
131  */
132  void
133  setHeadCentroid (bool head_centroid);
134 
135  /**
136  * \brief Set initial cluster indices.
137  *
138  * \param[in] cluster_indices Point cloud indices corresponding to the initial clusters (before subclustering).
139  */
140  void
141  setInitialClusters (std::vector<pcl::PointIndices>& cluster_indices);
142 
143  /**
144  * \brief Set minimum and maximum allowed height for a person cluster.
145  *
146  * \param[in] min_height Minimum allowed height for a person cluster (default = 1.3).
147  * \param[in] max_height Maximum allowed height for a person cluster (default = 2.3).
148  */
149  void
150  setHeightLimits (float min_height, float max_height);
151 
152  /**
153  * \brief Set minimum and maximum allowed number of points for a person cluster.
154  *
155  * \param[in] min_points Minimum allowed number of points for a person cluster.
156  * \param[in] max_points Maximum allowed number of points for a person cluster.
157  */
158  void
159  setDimensionLimits (int min_points, int max_points);
160 
161  /**
162  * \brief Set minimum distance between persons' heads.
163  *
164  * \param[in] heads_minimum_distance Minimum allowed distance between persons' heads (default = 0.3).
165  */
166  void
167  setMinimumDistanceBetweenHeads (float heads_minimum_distance);
168 
169  /**
170  * \brief Get minimum and maximum allowed height for a person cluster.
171  *
172  * \param[out] min_height Minimum allowed height for a person cluster.
173  * \param[out] max_height Maximum allowed height for a person cluster.
174  */
175  void
176  getHeightLimits (float& min_height, float& max_height);
177 
178  /**
179  * \brief Get minimum and maximum allowed number of points for a person cluster.
180  *
181  * \param[out] min_points Minimum allowed number of points for a person cluster.
182  * \param[out] max_points Maximum allowed number of points for a person cluster.
183  */
184  void
185  getDimensionLimits (int& min_points, int& max_points);
186 
187  /**
188  * \brief Get minimum distance between persons' heads.
189  */
190  float
192 
193  protected:
194  /** \brief ground plane coefficients */
195  Eigen::VectorXf ground_coeffs_;
196 
197  /** \brief ground plane normalization factor */
199 
200  /** \brief initial clusters indices */
201  std::vector<pcl::PointIndices> cluster_indices_;
202 
203  /** \brief pointer to the input cloud */
205 
206  /** \brief person clusters maximum height from the ground plane */
207  float max_height_;
208 
209  /** \brief person clusters minimum height from the ground plane */
210  float min_height_;
211 
212  /** \brief if true, the sensor is considered to be vertically placed (portrait mode) */
213  bool vertical_;
214 
215  /** \brief if true, the person centroid is computed as the centroid of the cluster points belonging to the head
216  if false, the person centroid is computed as the centroid of the whole cluster points (default = true) */
218 
219  /** \brief maximum number of points for a person cluster */
221 
222  /** \brief minimum number of points for a person cluster */
224 
225  /** \brief minimum distance between persons' heads */
227  };
228  } /* namespace people */
229 } /* namespace pcl */
230 #include <pcl/people/impl/head_based_subcluster.hpp>
231 #endif /* PCL_PEOPLE_HEAD_BASED_SUBCLUSTER_H_ */
void setDimensionLimits(int min_points, int max_points)
Set minimum and maximum allowed number of points for a person cluster.
float heads_minimum_distance_
minimum distance between persons' heads
void setGround(Eigen::VectorXf &ground_coeffs)
Set the ground coefficients.
float sqrt_ground_coeffs_
ground plane normalization factor
void getHeightLimits(float &min_height, float &max_height)
Get minimum and maximum allowed height for a person cluster.
void subcluster(std::vector< pcl::people::PersonCluster< PointT > > &clusters)
Compute subclusters and return them into a vector of PersonCluster.
float min_height_
person clusters minimum height from the ground plane
int min_points_
minimum number of points for a person cluster
PersonCluster represents a class for representing information about a cluster containing a person...
boost::shared_ptr< PointCloud > PointCloudPtr
boost::shared_ptr< const PointCloud > PointCloudConstPtr
PointCloudPtr cloud_
pointer to the input cloud
void createSubClusters(pcl::people::PersonCluster< PointT > &cluster, int maxima_number_after_filtering, std::vector< int > &maxima_cloud_indices_filtered, std::vector< pcl::people::PersonCluster< PointT > > &subclusters)
Create subclusters centered on the heads position from the current cluster.
int max_points_
maximum number of points for a person cluster
void setHeightLimits(float min_height, float max_height)
Set minimum and maximum allowed height for a person cluster.
bool head_centroid_
if true, the person centroid is computed as the centroid of the cluster points belonging to the head ...
HeadBasedSubclustering represents a class for searching for people inside a HeightMap2D based on a 3D...
void setHeadCentroid(bool head_centroid)
Set head_centroid_ to true (person centroid is in the head) or false (person centroid is the whole bo...
void setInitialClusters(std::vector< pcl::PointIndices > &cluster_indices)
Set initial cluster indices.
void mergeClustersCloseInFloorCoordinates(std::vector< pcl::people::PersonCluster< PointT > > &input_clusters, std::vector< pcl::people::PersonCluster< PointT > > &output_clusters)
Merge clusters close in floor coordinates.
float max_height_
person clusters maximum height from the ground plane
void setMinimumDistanceBetweenHeads(float heads_minimum_distance)
Set minimum distance between persons' heads.
void setSensorPortraitOrientation(bool vertical)
Set sensor orientation to landscape mode (false) or portrait mode (true).
void setInputCloud(PointCloudPtr &cloud)
Set input cloud.
bool vertical_
if true, the sensor is considered to be vertically placed (portrait mode)
Eigen::VectorXf ground_coeffs_
ground plane coefficients
std::vector< pcl::PointIndices > cluster_indices_
initial clusters indices
void getDimensionLimits(int &min_points, int &max_points)
Get minimum and maximum allowed number of points for a person cluster.
float getMinimumDistanceBetweenHeads()
Get minimum distance between persons' heads.