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 * ground_based_people_detection_app.h 00037 * Created on: Nov 30, 2012 00038 * Author: Matteo Munaro 00039 */ 00040 00041 #ifndef PCL_PEOPLE_GROUND_BASED_PEOPLE_DETECTION_APP_H_ 00042 #define PCL_PEOPLE_GROUND_BASED_PEOPLE_DETECTION_APP_H_ 00043 00044 #include <pcl/point_types.h> 00045 #include <pcl/sample_consensus/sac_model_plane.h> 00046 #include <pcl/sample_consensus/ransac.h> 00047 #include <pcl/filters/extract_indices.h> 00048 #include <pcl/segmentation/extract_clusters.h> 00049 #include <pcl/kdtree/kdtree.h> 00050 #include <pcl/filters/voxel_grid.h> 00051 #include <pcl/people/person_cluster.h> 00052 #include <pcl/people/head_based_subcluster.h> 00053 #include <pcl/people/person_classifier.h> 00054 00055 namespace pcl 00056 { 00057 namespace people 00058 { 00068 template <typename PointT> class GroundBasedPeopleDetectionApp; 00069 00070 template <typename PointT> 00071 class GroundBasedPeopleDetectionApp 00072 { 00073 public: 00074 00075 typedef pcl::PointCloud<PointT> PointCloud; 00076 typedef boost::shared_ptr<PointCloud> PointCloudPtr; 00077 typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr; 00078 00080 GroundBasedPeopleDetectionApp (); 00081 00083 virtual ~GroundBasedPeopleDetectionApp (); 00084 00090 void 00091 setInputCloud (PointCloudPtr& cloud); 00092 00098 void 00099 setGround (Eigen::VectorXf& ground_coeffs); 00100 00106 void 00107 setSamplingFactor (int sampling_factor); 00108 00114 void 00115 setVoxelSize (float voxel_size); 00116 00122 void 00123 setIntrinsics (Eigen::Matrix3f intrinsics_matrix); 00124 00130 void 00131 setClassifier (pcl::people::PersonClassifier<pcl::RGB> person_classifier); 00132 00138 void 00139 setSensorPortraitOrientation (bool vertical); 00140 00146 void 00147 setHeadCentroid (bool head_centroid); 00148 00155 void 00156 setHeightLimits (float min_height, float max_height); 00157 00164 void 00165 setDimensionLimits (int min_points, int max_points); 00166 00172 void 00173 setMinimumDistanceBetweenHeads (float heads_minimum_distance); 00174 00181 void 00182 getHeightLimits (float& min_height, float& max_height); 00183 00190 void 00191 getDimensionLimits (int& min_points, int& max_points); 00192 00196 float 00197 getMinimumDistanceBetweenHeads (); 00198 00202 Eigen::VectorXf 00203 getGround (); 00204 00208 PointCloudPtr 00209 getNoGroundCloud (); 00210 00217 void 00218 extractRGBFromPointCloud (PointCloudPtr input_cloud, pcl::PointCloud<pcl::RGB>::Ptr& output_cloud); 00219 00225 void 00226 swapDimensions (pcl::PointCloud<pcl::RGB>::Ptr& cloud); 00227 00235 bool 00236 compute (std::vector<pcl::people::PersonCluster<PointT> >& clusters); 00237 00238 protected: 00240 int sampling_factor_; 00241 00243 float voxel_size_; 00244 00246 Eigen::VectorXf ground_coeffs_; 00247 00249 float sqrt_ground_coeffs_; 00250 00252 PointCloudPtr cloud_; 00253 00255 PointCloudPtr no_ground_cloud_; 00256 00258 pcl::PointCloud<pcl::RGB>::Ptr rgb_image_; 00259 00261 float max_height_; 00262 00264 float min_height_; 00265 00267 bool vertical_; 00268 00271 bool head_centroid_; // if true, the person centroid is computed as the centroid of the cluster points belonging to the head (default = true) 00272 // if false, the person centroid is computed as the centroid of the whole cluster points 00274 int max_points_; 00275 00277 int min_points_; 00278 00280 bool dimension_limits_set_; 00281 00283 float heads_minimum_distance_; 00284 00286 Eigen::Matrix3f intrinsics_matrix_; 00287 00289 pcl::people::PersonClassifier<pcl::RGB> person_classifier_; 00290 00292 bool person_classifier_set_flag_; 00293 }; 00294 } /* namespace people */ 00295 } /* namespace pcl */ 00296 #include <pcl/people/impl/ground_based_people_detection_app.hpp> 00297 #endif /* PCL_PEOPLE_GROUND_BASED_PEOPLE_DETECTION_APP_H_ */