|
Point Cloud Library (PCL)
1.4.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2011, Willow Garage, 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 Willow Garage, Inc. 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 * $Id: cvfh.h 3755 2011-12-31 23:45:30Z rusu $ 00037 * 00038 */ 00039 00040 #ifndef PCL_FEATURES_CVFH_H_ 00041 #define PCL_FEATURES_CVFH_H_ 00042 00043 #include <pcl/features/feature.h> 00044 #include <pcl/features/normal_3d.h> 00045 #include <pcl/features/vfh.h> 00046 #include <pcl/search/pcl_search.h> 00047 #include <pcl/common/common.h> 00048 00049 namespace pcl 00050 { 00058 template<typename PointInT, typename PointNT, typename PointOutT> 00059 class CVFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00060 { 00061 public: 00062 using Feature<PointInT, PointOutT>::feature_name_; 00063 using Feature<PointInT, PointOutT>::getClassName; 00064 using Feature<PointInT, PointOutT>::indices_; 00065 using Feature<PointInT, PointOutT>::k_; 00066 using Feature<PointInT, PointOutT>::search_radius_; 00067 using Feature<PointInT, PointOutT>::surface_; 00068 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00069 00070 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00071 typedef typename pcl::search::Search<PointNormal>::Ptr KdTreePtr; 00072 typedef typename pcl::NormalEstimation<PointNormal, PointNormal> NormalEstimator; 00073 typedef typename pcl::VFHEstimation<PointInT, PointNT, pcl::VFHSignature308> VFHEstimator; 00074 00076 CVFHEstimation () : 00077 vpx_ (0), vpy_ (0), vpz_ (0), 00078 leaf_size_ (0.005), curv_threshold_ (0.03), 00079 cluster_tolerance_ (leaf_size_ * 3), eps_angle_threshold_ (0.125), min_points_ (50) 00080 { 00081 search_radius_ = 0; 00082 k_ = 1; 00083 feature_name_ = "CVFHEstimation"; 00084 normalize_bins_ = false; 00085 radius_normals_ = leaf_size_ * 3; 00086 } 00087 ; 00088 00095 void 00096 filterNormalsWithHighCurvature (const pcl::PointCloud<PointNT> & cloud, std::vector<int> &indices_out, 00097 std::vector<int> &indices_in, float threshold); 00098 00104 inline void 00105 setViewPoint (float vpx, float vpy, float vpz) 00106 { 00107 vpx_ = vpx; 00108 vpy_ = vpy; 00109 vpz_ = vpz; 00110 } 00111 00115 inline void 00116 setRadiusNormals (float radius_normals) 00117 { 00118 radius_normals_ = radius_normals; 00119 } 00120 00126 inline void 00127 getViewPoint (float &vpx, float &vpy, float &vpz) 00128 { 00129 vpx = vpx_; 00130 vpy = vpy_; 00131 vpz = vpz_; 00132 } 00133 00137 inline void 00138 getCentroidClusters (std::vector<Eigen::Vector3f> & centroids) 00139 { 00140 for (size_t i = 0; i < centroids_dominant_orientations_.size (); ++i) 00141 centroids.push_back (centroids_dominant_orientations_[i]); 00142 } 00143 00147 inline void 00148 getCentroidNormalClusters (std::vector<Eigen::Vector3f> & centroids) 00149 { 00150 for (size_t i = 0; i < dominant_normals_.size (); ++i) 00151 centroids.push_back (dominant_normals_[i]); 00152 } 00153 00158 inline void 00159 setClusterTolerance (float d) 00160 { 00161 cluster_tolerance_ = d; 00162 } 00163 00167 inline void 00168 setEPSAngleThreshold (float d) 00169 { 00170 eps_angle_threshold_ = d; 00171 } 00172 00176 inline void 00177 setCurvatureThreshold (float d) 00178 { 00179 curv_threshold_ = d; 00180 } 00181 00185 inline void 00186 setMinPoints (size_t min) 00187 { 00188 min_points_ = min; 00189 } 00190 00194 inline void 00195 setNormalizeBins (bool normalize) 00196 { 00197 normalize_bins_ = normalize; 00198 } 00199 00200 private: 00204 float vpx_, vpy_, vpz_; 00205 00209 float leaf_size_; 00210 00212 bool normalize_bins_; 00213 00215 float curv_threshold_; 00216 00218 float cluster_tolerance_; 00219 00221 float eps_angle_threshold_; 00222 00226 size_t min_points_; 00227 00229 float radius_normals_; 00230 00238 void 00239 computeFeature (PointCloudOut &output); 00240 00254 void 00255 extractEuclideanClustersSmooth (const pcl::PointCloud<pcl::PointNormal> &cloud, 00256 const pcl::PointCloud<pcl::PointNormal> &normals, float tolerance, 00257 const pcl::search::Search<pcl::PointNormal>::Ptr &tree, 00258 std::vector<pcl::PointIndices> &clusters, double eps_angle, 00259 unsigned int min_pts_per_cluster = 1, 00260 unsigned int max_pts_per_cluster = (std::numeric_limits<int>::max) ()); 00261 00262 protected: 00264 std::vector<Eigen::Vector3f> centroids_dominant_orientations_; 00266 std::vector<Eigen::Vector3f> dominant_normals_; 00267 00268 private: 00272 void 00273 computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output) {} 00274 }; 00275 00276 } 00277 00278 #endif //#ifndef PCL_FEATURES_VFH_H_
1.7.6.1