Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2013-, Open Perception, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of the copyright holder(s) nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * head_based_subcluster.h 00037 * Created on: Nov 30, 2012 00038 * Author: Matteo Munaro 00039 */ 00040 00041 #ifndef PCL_PEOPLE_HEAD_BASED_SUBCLUSTER_H_ 00042 #define PCL_PEOPLE_HEAD_BASED_SUBCLUSTER_H_ 00043 00044 #include <pcl/people/person_cluster.h> 00045 #include <pcl/people/height_map_2d.h> 00046 #include <pcl/point_types.h> 00047 00048 namespace pcl 00049 { 00050 namespace people 00051 { 00052 /** \brief @b HeadBasedSubclustering represents a class for searching for people inside a HeightMap2D based on a 3D head detection algorithm 00053 * \author Matteo Munaro 00054 * \ingroup people 00055 */ 00056 template <typename PointT> class HeadBasedSubclustering; 00057 00058 template <typename PointT> 00059 class HeadBasedSubclustering 00060 { 00061 public: 00062 00063 typedef pcl::PointCloud<PointT> PointCloud; 00064 typedef boost::shared_ptr<PointCloud> PointCloudPtr; 00065 typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr; 00066 00067 /** \brief Constructor. */ 00068 HeadBasedSubclustering (); 00069 00070 /** \brief Destructor. */ 00071 virtual ~HeadBasedSubclustering (); 00072 00073 /** 00074 * \brief Compute subclusters and return them into a vector of PersonCluster. 00075 * 00076 * \param[in] clusters Vector of PersonCluster. 00077 */ 00078 void 00079 subcluster (std::vector<pcl::people::PersonCluster<PointT> >& clusters); 00080 00081 /** 00082 * \brief Merge clusters close in floor coordinates. 00083 * 00084 * \param[in] input_clusters Input vector of PersonCluster. 00085 * \param[in] output_clusters Output vector of PersonCluster (after merging). 00086 */ 00087 void 00088 mergeClustersCloseInFloorCoordinates (std::vector<pcl::people::PersonCluster<PointT> >& input_clusters, 00089 std::vector<pcl::people::PersonCluster<PointT> >& output_clusters); 00090 00091 /** 00092 * \brief Create subclusters centered on the heads position from the current cluster. 00093 * 00094 * \param[in] cluster A PersonCluster. 00095 * \param[in] maxima_number Number of local maxima to use as centers of the new cluster. 00096 * \param[in] maxima_cloud_indices Cloud indices of local maxima to use as centers of the new cluster. 00097 * \param[out] subclusters Output vector of PersonCluster objects derived from the input cluster. 00098 */ 00099 void 00100 createSubClusters (pcl::people::PersonCluster<PointT>& cluster, int maxima_number_after_filtering, std::vector<int>& maxima_cloud_indices_filtered, 00101 std::vector<pcl::people::PersonCluster<PointT> >& subclusters); 00102 00103 /** 00104 * \brief Set input cloud. 00105 * 00106 * \param[in] cloud A pointer to the input point cloud. 00107 */ 00108 void 00109 setInputCloud (PointCloudPtr& cloud); 00110 00111 /** 00112 * \brief Set the ground coefficients. 00113 * 00114 * \param[in] ground_coeffs The ground plane coefficients. 00115 */ 00116 void 00117 setGround (Eigen::VectorXf& ground_coeffs); 00118 00119 /** 00120 * \brief Set sensor orientation to landscape mode (false) or portrait mode (true). 00121 * 00122 * \param[in] vertical Landscape (false) or portrait (true) mode (default = false). 00123 */ 00124 void 00125 setSensorPortraitOrientation (bool vertical); 00126 00127 /** 00128 * \brief Set head_centroid_ to true (person centroid is in the head) or false (person centroid is the whole body centroid). 00129 * 00130 * \param[in] head_centroid Set the location of the person centroid (head or body center) (default = true). 00131 */ 00132 void 00133 setHeadCentroid (bool head_centroid); 00134 00135 /** 00136 * \brief Set initial cluster indices. 00137 * 00138 * \param[in] cluster_indices Point cloud indices corresponding to the initial clusters (before subclustering). 00139 */ 00140 void 00141 setInitialClusters (std::vector<pcl::PointIndices>& cluster_indices); 00142 00143 /** 00144 * \brief Set minimum and maximum allowed height for a person cluster. 00145 * 00146 * \param[in] min_height Minimum allowed height for a person cluster (default = 1.3). 00147 * \param[in] max_height Maximum allowed height for a person cluster (default = 2.3). 00148 */ 00149 void 00150 setHeightLimits (float min_height, float max_height); 00151 00152 /** 00153 * \brief Set minimum and maximum allowed number of points for a person cluster. 00154 * 00155 * \param[in] min_points Minimum allowed number of points for a person cluster. 00156 * \param[in] max_points Maximum allowed number of points for a person cluster. 00157 */ 00158 void 00159 setDimensionLimits (int min_points, int max_points); 00160 00161 /** 00162 * \brief Set minimum distance between persons' heads. 00163 * 00164 * \param[in] heads_minimum_distance Minimum allowed distance between persons' heads (default = 0.3). 00165 */ 00166 void 00167 setMinimumDistanceBetweenHeads (float heads_minimum_distance); 00168 00169 /** 00170 * \brief Get minimum and maximum allowed height for a person cluster. 00171 * 00172 * \param[out] min_height Minimum allowed height for a person cluster. 00173 * \param[out] max_height Maximum allowed height for a person cluster. 00174 */ 00175 void 00176 getHeightLimits (float& min_height, float& max_height); 00177 00178 /** 00179 * \brief Get minimum and maximum allowed number of points for a person cluster. 00180 * 00181 * \param[out] min_points Minimum allowed number of points for a person cluster. 00182 * \param[out] max_points Maximum allowed number of points for a person cluster. 00183 */ 00184 void 00185 getDimensionLimits (int& min_points, int& max_points); 00186 00187 /** 00188 * \brief Get minimum distance between persons' heads. 00189 */ 00190 float 00191 getMinimumDistanceBetweenHeads (); 00192 00193 protected: 00194 /** \brief ground plane coefficients */ 00195 Eigen::VectorXf ground_coeffs_; 00196 00197 /** \brief ground plane normalization factor */ 00198 float sqrt_ground_coeffs_; 00199 00200 /** \brief initial clusters indices */ 00201 std::vector<pcl::PointIndices> cluster_indices_; 00202 00203 /** \brief pointer to the input cloud */ 00204 PointCloudPtr cloud_; 00205 00206 /** \brief person clusters maximum height from the ground plane */ 00207 float max_height_; 00208 00209 /** \brief person clusters minimum height from the ground plane */ 00210 float min_height_; 00211 00212 /** \brief if true, the sensor is considered to be vertically placed (portrait mode) */ 00213 bool vertical_; 00214 00215 /** \brief if true, the person centroid is computed as the centroid of the cluster points belonging to the head 00216 if false, the person centroid is computed as the centroid of the whole cluster points (default = true) */ 00217 bool head_centroid_; 00218 00219 /** \brief maximum number of points for a person cluster */ 00220 int max_points_; 00221 00222 /** \brief minimum number of points for a person cluster */ 00223 int min_points_; 00224 00225 /** \brief minimum distance between persons' heads */ 00226 float heads_minimum_distance_; 00227 }; 00228 } /* namespace people */ 00229 } /* namespace pcl */ 00230 #include <pcl/people/impl/head_based_subcluster.hpp> 00231 #endif /* PCL_PEOPLE_HEAD_BASED_SUBCLUSTER_H_ */