00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef PCL_FEATURES_VFH_H_
00042 #define PCL_FEATURES_VFH_H_
00043
00044 #include <pcl/point_types.h>
00045 #include <pcl/features/feature.h>
00046
00047 namespace pcl
00048 {
00070 template<typename PointInT, typename PointNT, typename PointOutT = pcl::VFHSignature308>
00071 class VFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
00072 {
00073 public:
00074 using Feature<PointInT, PointOutT>::feature_name_;
00075 using Feature<PointInT, PointOutT>::getClassName;
00076 using Feature<PointInT, PointOutT>::indices_;
00077 using Feature<PointInT, PointOutT>::k_;
00078 using Feature<PointInT, PointOutT>::search_radius_;
00079 using Feature<PointInT, PointOutT>::input_;
00080 using Feature<PointInT, PointOutT>::surface_;
00081 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
00082
00083 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00084 typedef typename boost::shared_ptr<VFHEstimation<PointInT, PointNT, PointOutT> > Ptr;
00085 typedef typename boost::shared_ptr<const VFHEstimation<PointInT, PointNT, PointOutT> > ConstPtr;
00086
00087
00089 VFHEstimation () :
00090 nr_bins_f1_ (45), nr_bins_f2_ (45), nr_bins_f3_ (45), nr_bins_f4_ (45), nr_bins_vp_ (128),
00091 vpx_ (0), vpy_ (0), vpz_ (0),
00092 hist_f1_ (), hist_f2_ (), hist_f3_ (), hist_f4_ (), hist_vp_ (),
00093 normal_to_use_ (), centroid_to_use_ (), use_given_normal_ (false), use_given_centroid_ (false),
00094 normalize_bins_ (true), normalize_distances_ (false), size_component_ (false),
00095 d_pi_ (1.0f / (2.0f * static_cast<float> (M_PI)))
00096 {
00097 hist_f1_.setZero (nr_bins_f1_);
00098 hist_f2_.setZero (nr_bins_f2_);
00099 hist_f3_.setZero (nr_bins_f3_);
00100 hist_f4_.setZero (nr_bins_f4_);
00101 search_radius_ = 0;
00102 k_ = 0;
00103 feature_name_ = "VFHEstimation";
00104 }
00105
00114 void
00115 computePointSPFHSignature (const Eigen::Vector4f ¢roid_p, const Eigen::Vector4f ¢roid_n,
00116 const pcl::PointCloud<PointInT> &cloud, const pcl::PointCloud<PointNT> &normals,
00117 const std::vector<int> &indices);
00118
00124 inline void
00125 setViewPoint (float vpx, float vpy, float vpz)
00126 {
00127 vpx_ = vpx;
00128 vpy_ = vpy;
00129 vpz_ = vpz;
00130 }
00131
00133 inline void
00134 getViewPoint (float &vpx, float &vpy, float &vpz)
00135 {
00136 vpx = vpx_;
00137 vpy = vpy_;
00138 vpz = vpz_;
00139 }
00140
00144 inline void
00145 setUseGivenNormal (bool use)
00146 {
00147 use_given_normal_ = use;
00148 }
00149
00154 inline void
00155 setNormalToUse (const Eigen::Vector3f &normal)
00156 {
00157 normal_to_use_ = Eigen::Vector4f (normal[0], normal[1], normal[2], 0);
00158 }
00159
00163 inline void
00164 setUseGivenCentroid (bool use)
00165 {
00166 use_given_centroid_ = use;
00167 }
00168
00173 inline void
00174 setCentroidToUse (const Eigen::Vector3f ¢roid)
00175 {
00176 centroid_to_use_ = Eigen::Vector4f (centroid[0], centroid[1], centroid[2], 0);
00177 }
00178
00182 inline void
00183 setNormalizeBins (bool normalize)
00184 {
00185 normalize_bins_ = normalize;
00186 }
00187
00192 inline void
00193 setNormalizeDistance (bool normalize)
00194 {
00195 normalize_distances_ = normalize;
00196 }
00197
00202 inline void
00203 setFillSizeComponent (bool fill_size)
00204 {
00205 size_component_ = fill_size;
00206 }
00207
00211 void
00212 compute (PointCloudOut &output);
00213
00214 private:
00215
00217 int nr_bins_f1_, nr_bins_f2_, nr_bins_f3_, nr_bins_f4_, nr_bins_vp_;
00218
00222 float vpx_, vpy_, vpz_;
00223
00229 void
00230 computeFeature (PointCloudOut &output);
00231
00232 protected:
00234 bool
00235 initCompute ();
00236
00238 Eigen::VectorXf hist_f1_;
00240 Eigen::VectorXf hist_f2_;
00242 Eigen::VectorXf hist_f3_;
00244 Eigen::VectorXf hist_f4_;
00246 Eigen::VectorXf hist_vp_;
00247
00249 Eigen::Vector4f normal_to_use_;
00251 Eigen::Vector4f centroid_to_use_;
00252
00253
00254
00256 bool use_given_normal_;
00258 bool use_given_centroid_;
00260 bool normalize_bins_;
00262 bool normalize_distances_;
00264 bool size_component_;
00265
00266 private:
00268 float d_pi_;
00269
00273 void
00274 computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &) {}
00275 };
00276
00292
00293
00294
00295
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 }
00320
00321 #endif //#ifndef PCL_FEATURES_VFH_H_