Point Cloud Library (PCL)
1.3.1
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2009, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * $Id: cvfh.h 3022 2011-11-01 03:42:22Z rusu $ 00035 * 00036 */ 00037 00038 #ifndef PCL_FEATURES_CVFH_H_ 00039 #define PCL_FEATURES_CVFH_H_ 00040 00041 #include <pcl/features/feature.h> 00042 #include <pcl/features/normal_3d.h> 00043 #include <pcl/features/vfh.h> 00044 #include <pcl/search/pcl_search.h> 00045 #include <pcl/common/common.h> 00046 00047 namespace pcl 00048 { 00054 template<typename PointInT, typename PointNT, typename PointOutT> 00055 class CVFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00056 { 00057 public: 00058 using Feature<PointInT, PointOutT>::feature_name_; 00059 using Feature<PointInT, PointOutT>::getClassName; 00060 using Feature<PointInT, PointOutT>::indices_; 00061 using Feature<PointInT, PointOutT>::k_; 00062 using Feature<PointInT, PointOutT>::search_radius_; 00063 using Feature<PointInT, PointOutT>::surface_; 00064 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00065 00066 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00067 typedef typename pcl::search::Search<PointNormal>::Ptr KdTreePtr; 00068 typedef typename pcl::NormalEstimation<PointNormal, PointNormal> NormalEstimator; 00069 typedef typename pcl::VFHEstimation<PointInT, PointNT, pcl::VFHSignature308> VFHEstimator; 00070 00071 pcl::PointCloud<pcl::PointXYZINormal>::Ptr clusters_colored_; 00072 00074 CVFHEstimation () : 00075 vpx_ (0), vpy_ (0), vpz_ (0), leaf_size_ (0.005), curv_threshold_ (0.03), cluster_tolerance_ (leaf_size_ * 3), 00076 eps_angle_threshold_ (0.125), min_points_ (50) 00077 { 00078 search_radius_ = 0; 00079 k_ = 1; 00080 feature_name_ = "CVFHEstimation"; 00081 normalize_bins_ = false; 00082 radius_normals_ = leaf_size_ * 3; 00083 } 00084 ; 00085 00092 void 00093 filterNormalsWithHighCurvature (const pcl::PointCloud<PointNT> & cloud, std::vector<int> & indices_out, 00094 std::vector<int> & indices_in, float threshold); 00095 00101 inline void 00102 setViewPoint (float vpx, float vpy, float vpz) 00103 { 00104 vpx_ = vpx; 00105 vpy_ = vpy; 00106 vpz_ = vpz; 00107 } 00108 00112 inline void 00113 setRadiusNormals (float radius_normals) 00114 { 00115 radius_normals_ = radius_normals; 00116 } 00117 00123 inline void 00124 getViewPoint (float &vpx, float &vpy, float &vpz) 00125 { 00126 vpx = vpx_; 00127 vpy = vpy_; 00128 vpz = vpz_; 00129 } 00130 00134 inline void 00135 getCentroidClusters (std::vector<Eigen::Vector3f> & centroids) 00136 { 00137 for (size_t i = 0; i < centroids_dominant_orientations_.size (); ++i) 00138 centroids.push_back (centroids_dominant_orientations_[i]); 00139 } 00140 00142 inline void 00143 setClusterTolerance (float d) 00144 { 00145 cluster_tolerance_ = d; 00146 } 00147 00150 inline void 00151 setEPSAngleThreshold (float d) 00152 { 00153 eps_angle_threshold_ = d; 00154 } 00155 00159 inline void 00160 setCurvatureThreshold (float d) 00161 { 00162 curv_threshold_ = d; 00163 } 00164 00165 /* 00166 * \brief Set minimum amount of points for a cluster to be considered 00167 */ 00168 inline void 00169 setMinPoints (size_t min) 00170 { 00171 min_points_ = min; 00172 } 00173 00174 /* 00175 * \brief Sets wether if the CVFH signatures should be normalized or not 00176 */ 00177 inline void 00178 setNormalizeBins (bool normalize) 00179 { 00180 normalize_bins_ = normalize; 00181 } 00182 00183 private: 00187 float vpx_, vpy_, vpz_; 00188 00192 float leaf_size_; 00193 00196 bool normalize_bins_; 00197 00199 float curv_threshold_; 00200 00202 float cluster_tolerance_; 00203 00207 float eps_angle_threshold_; 00208 00212 size_t min_points_; 00213 00216 float radius_normals_; 00217 00225 void 00226 computeFeature (PointCloudOut &output); 00227 00241 void 00242 extractEuclideanClustersSmooth (const pcl::PointCloud<pcl::PointNormal> &cloud, 00243 const pcl::PointCloud<pcl::PointNormal> &normals, float tolerance, 00244 const pcl::search::Search<pcl::PointNormal>::Ptr &tree, 00245 std::vector<pcl::PointIndices> &clusters, double eps_angle, 00246 unsigned int min_pts_per_cluster = 1, 00247 unsigned int max_pts_per_cluster = (std::numeric_limits<int>::max) ()); 00248 00249 protected: 00251 std::vector<Eigen::Vector3f> centroids_dominant_orientations_; 00252 }; 00253 } 00254 00255 #endif //#ifndef PCL_FEATURES_VFH_H_