|
Point Cloud Library (PCL)
1.5.1
|
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 4702 2012-02-23 09:39:33Z gedikli $ 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 { 00063 template<typename PointInT, typename PointNT, typename PointOutT = pcl::VFHSignature308> 00064 class CVFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00065 { 00066 public: 00067 using Feature<PointInT, PointOutT>::feature_name_; 00068 using Feature<PointInT, PointOutT>::getClassName; 00069 using Feature<PointInT, PointOutT>::indices_; 00070 using Feature<PointInT, PointOutT>::k_; 00071 using Feature<PointInT, PointOutT>::search_radius_; 00072 using Feature<PointInT, PointOutT>::surface_; 00073 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00074 00075 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00076 typedef typename pcl::search::Search<PointNormal>::Ptr KdTreePtr; 00077 typedef typename pcl::NormalEstimation<PointNormal, PointNormal> NormalEstimator; 00078 typedef typename pcl::VFHEstimation<PointInT, PointNT, pcl::VFHSignature308> VFHEstimator; 00079 00081 CVFHEstimation () : 00082 vpx_ (0), vpy_ (0), vpz_ (0), 00083 leaf_size_ (0.005), curv_threshold_ (0.03), 00084 cluster_tolerance_ (leaf_size_ * 3), eps_angle_threshold_ (0.125), min_points_ (50) 00085 { 00086 search_radius_ = 0; 00087 k_ = 1; 00088 feature_name_ = "CVFHEstimation"; 00089 normalize_bins_ = false; 00090 radius_normals_ = leaf_size_ * 3; 00091 } 00092 ; 00093 00100 void 00101 filterNormalsWithHighCurvature (const pcl::PointCloud<PointNT> & cloud, std::vector<int> &indices_out, 00102 std::vector<int> &indices_in, float threshold); 00103 00109 inline void 00110 setViewPoint (float vpx, float vpy, float vpz) 00111 { 00112 vpx_ = vpx; 00113 vpy_ = vpy; 00114 vpz_ = vpz; 00115 } 00116 00120 inline void 00121 setRadiusNormals (float radius_normals) 00122 { 00123 radius_normals_ = radius_normals; 00124 } 00125 00131 inline void 00132 getViewPoint (float &vpx, float &vpy, float &vpz) 00133 { 00134 vpx = vpx_; 00135 vpy = vpy_; 00136 vpz = vpz_; 00137 } 00138 00142 inline void 00143 getCentroidClusters (std::vector<Eigen::Vector3f> & centroids) 00144 { 00145 for (size_t i = 0; i < centroids_dominant_orientations_.size (); ++i) 00146 centroids.push_back (centroids_dominant_orientations_[i]); 00147 } 00148 00152 inline void 00153 getCentroidNormalClusters (std::vector<Eigen::Vector3f> & centroids) 00154 { 00155 for (size_t i = 0; i < dominant_normals_.size (); ++i) 00156 centroids.push_back (dominant_normals_[i]); 00157 } 00158 00163 inline void 00164 setClusterTolerance (float d) 00165 { 00166 cluster_tolerance_ = d; 00167 } 00168 00172 inline void 00173 setEPSAngleThreshold (float d) 00174 { 00175 eps_angle_threshold_ = d; 00176 } 00177 00181 inline void 00182 setCurvatureThreshold (float d) 00183 { 00184 curv_threshold_ = d; 00185 } 00186 00190 inline void 00191 setMinPoints (size_t min) 00192 { 00193 min_points_ = min; 00194 } 00195 00199 inline void 00200 setNormalizeBins (bool normalize) 00201 { 00202 normalize_bins_ = normalize; 00203 } 00204 00205 private: 00209 float vpx_, vpy_, vpz_; 00210 00214 float leaf_size_; 00215 00217 bool normalize_bins_; 00218 00220 float curv_threshold_; 00221 00223 float cluster_tolerance_; 00224 00226 float eps_angle_threshold_; 00227 00231 size_t min_points_; 00232 00234 float radius_normals_; 00235 00243 void 00244 computeFeature (PointCloudOut &output); 00245 00259 void 00260 extractEuclideanClustersSmooth (const pcl::PointCloud<pcl::PointNormal> &cloud, 00261 const pcl::PointCloud<pcl::PointNormal> &normals, float tolerance, 00262 const pcl::search::Search<pcl::PointNormal>::Ptr &tree, 00263 std::vector<pcl::PointIndices> &clusters, double eps_angle, 00264 unsigned int min_pts_per_cluster = 1, 00265 unsigned int max_pts_per_cluster = (std::numeric_limits<int>::max) ()); 00266 00267 protected: 00269 std::vector<Eigen::Vector3f> centroids_dominant_orientations_; 00271 std::vector<Eigen::Vector3f> dominant_normals_; 00272 00273 private: 00277 void 00278 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output) {} 00279 }; 00280 00281 } 00282 00283 #endif //#ifndef PCL_FEATURES_VFH_H_
1.8.0