|
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: vfh.h 4702 2012-02-23 09:39:33Z gedikli $ 00037 * 00038 */ 00039 00040 #ifndef PCL_FEATURES_VFH_H_ 00041 #define PCL_FEATURES_VFH_H_ 00042 00043 #include <pcl/point_types.h> 00044 #include <pcl/features/feature.h> 00045 00046 namespace pcl 00047 { 00068 template<typename PointInT, typename PointNT, typename PointOutT = pcl::VFHSignature308> 00069 class VFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT> 00070 { 00071 public: 00072 using Feature<PointInT, PointOutT>::feature_name_; 00073 using Feature<PointInT, PointOutT>::getClassName; 00074 using Feature<PointInT, PointOutT>::indices_; 00075 using Feature<PointInT, PointOutT>::k_; 00076 using Feature<PointInT, PointOutT>::search_radius_; 00077 using Feature<PointInT, PointOutT>::input_; 00078 using Feature<PointInT, PointOutT>::surface_; 00079 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_; 00080 00081 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00082 00084 VFHEstimation () : 00085 nr_bins_f1_ (45), nr_bins_f2_ (45), nr_bins_f3_ (45), nr_bins_f4_ (45), nr_bins_vp_ (128), vpx_ (0), vpy_ (0), 00086 vpz_ (0), d_pi_ (1.0 / (2.0 * M_PI)) 00087 { 00088 hist_f1_.setZero (nr_bins_f1_); 00089 hist_f2_.setZero (nr_bins_f2_); 00090 hist_f3_.setZero (nr_bins_f3_); 00091 hist_f4_.setZero (nr_bins_f4_); 00092 search_radius_ = 0; 00093 k_ = 0; 00094 feature_name_ = "VFHEstimation"; 00095 00096 //default parameters to compute VFH 00097 use_given_normal_ = false; 00098 use_given_centroid_ = false; 00099 normalize_bins_ = true; 00100 normalize_distances_ = false; 00101 size_component_ = false; 00102 } 00103 00112 void 00113 computePointSPFHSignature (const Eigen::Vector4f ¢roid_p, const Eigen::Vector4f ¢roid_n, 00114 const pcl::PointCloud<PointInT> &cloud, const pcl::PointCloud<PointNT> &normals, 00115 const std::vector<int> &indices); 00116 00122 inline void 00123 setViewPoint (float vpx, float vpy, float vpz) 00124 { 00125 vpx_ = vpx; 00126 vpy_ = vpy; 00127 vpz_ = vpz; 00128 } 00129 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 setUseGivenNormal (bool use) 00144 { 00145 use_given_normal_ = use; 00146 } 00147 00152 inline void 00153 setNormalToUse (const Eigen::Vector3f &normal) 00154 { 00155 normal_to_use_ = Eigen::Vector4f (normal[0], normal[1], normal[2], 0); 00156 } 00157 00161 inline void 00162 setUseGivenCentroid (bool use) 00163 { 00164 use_given_centroid_ = use; 00165 } 00166 00171 inline void 00172 setCentroidToUse (const Eigen::Vector3f ¢roid) 00173 { 00174 centroid_to_use_ = Eigen::Vector4f (centroid[0], centroid[1], centroid[2], 0); 00175 } 00176 00180 inline void 00181 setNormalizeBins (bool normalize) 00182 { 00183 normalize_bins_ = normalize; 00184 } 00185 00190 inline void 00191 setNormalizeDistance (bool normalize) 00192 { 00193 normalize_distances_ = normalize; 00194 } 00195 00200 inline void 00201 setFillSizeComponent (bool fill_size) 00202 { 00203 size_component_ = fill_size; 00204 } 00205 00206 private: 00207 00209 int nr_bins_f1_, nr_bins_f2_, nr_bins_f3_, nr_bins_f4_, nr_bins_vp_; 00210 00214 float vpx_, vpy_, vpz_; 00215 00221 void 00222 computeFeature (PointCloudOut &output); 00223 00224 protected: 00226 bool 00227 initCompute (); 00228 00230 Eigen::VectorXf hist_f1_; 00232 Eigen::VectorXf hist_f2_; 00234 Eigen::VectorXf hist_f3_; 00236 Eigen::VectorXf hist_f4_; 00238 Eigen::VectorXf hist_vp_; 00239 00241 Eigen::Vector4f normal_to_use_; 00243 Eigen::Vector4f centroid_to_use_; 00244 00245 // VFH configuration parameters because CVFH instantiates it. See constructor for default values. 00246 00248 bool use_given_normal_; 00250 bool use_given_centroid_; 00252 bool normalize_bins_; 00254 bool normalize_distances_; 00256 bool size_component_; 00257 00258 private: 00260 float d_pi_; 00261 00265 void 00266 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output) {} 00267 }; 00268 00284 // template<typename PointInT, typename PointNT> 00285 // class VFHEstimation<PointInT, PointNT, Eigen::MatrixXf> : public VFHEstimation<PointInT, PointNT, pcl::VFHSignature263> 00286 // { 00287 // public: 00295 // 00296 // private: 00297 // /** \brief Estimate the Viewpoint Feature Histograms (VFH) descriptors at a set of points given by 00298 // * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in 00299 // * setSearchMethod () 00300 // * \param[out] output the resultant point cloud model dataset that contains the VFH feature estimates 00301 // */ 00302 // void 00303 // computeFeature (pcl::PointCloud<Eigen::MatrixXf> &output); 00304 // 00305 // /** \brief Make the compute (&PointCloudOut); inaccessible from outside the class 00306 // * \param[out] output the output point cloud 00307 // */ 00308 // void 00309 // compute (pcl::PointCloud<pcl::Normal> &output) {} 00310 // }; 00311 } 00312 00313 #endif //#ifndef PCL_FEATURES_VFH_H_
1.8.0