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_PFH_H_
00042 #define PCL_PFH_H_
00043
00044 #include <pcl/point_types.h>
00045 #include <pcl/features/feature.h>
00046 #include <pcl/features/pfh_tools.h>
00047 #include <map>
00048
00049 namespace pcl
00050 {
00081 template <typename PointInT, typename PointNT, typename PointOutT = pcl::PFHSignature125>
00082 class PFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
00083 {
00084 public:
00085 typedef boost::shared_ptr<PFHEstimation<PointInT, PointNT, PointOutT> > Ptr;
00086 typedef boost::shared_ptr<const PFHEstimation<PointInT, PointNT, PointOutT> > ConstPtr;
00087 using Feature<PointInT, PointOutT>::feature_name_;
00088 using Feature<PointInT, PointOutT>::getClassName;
00089 using Feature<PointInT, PointOutT>::indices_;
00090 using Feature<PointInT, PointOutT>::k_;
00091 using Feature<PointInT, PointOutT>::search_parameter_;
00092 using Feature<PointInT, PointOutT>::surface_;
00093 using Feature<PointInT, PointOutT>::input_;
00094 using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
00095
00096 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00097 typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn;
00098
00102 PFHEstimation () :
00103 nr_subdiv_ (5),
00104 pfh_histogram_ (),
00105 pfh_tuple_ (),
00106 d_pi_ (1.0f / (2.0f * static_cast<float> (M_PI))),
00107 feature_map_ (),
00108 key_list_ (),
00109
00110 max_cache_size_ ((1ul*1024ul*1024ul*1024ul) / sizeof (std::pair<std::pair<int, int>, Eigen::Vector4f>)),
00111 use_cache_ (false)
00112 {
00113 feature_name_ = "PFHEstimation";
00114 };
00115
00119 inline void
00120 setMaximumCacheSize (unsigned int cache_size)
00121 {
00122 max_cache_size_ = cache_size;
00123 }
00124
00126 inline unsigned int
00127 getMaximumCacheSize ()
00128 {
00129 return (max_cache_size_);
00130 }
00131
00143 inline void
00144 setUseInternalCache (bool use_cache)
00145 {
00146 use_cache_ = use_cache;
00147 }
00148
00150 inline bool
00151 getUseInternalCache ()
00152 {
00153 return (use_cache_);
00154 }
00155
00170 bool
00171 computePairFeatures (const pcl::PointCloud<PointInT> &cloud, const pcl::PointCloud<PointNT> &normals,
00172 int p_idx, int q_idx, float &f1, float &f2, float &f3, float &f4);
00173
00182 void
00183 computePointPFHSignature (const pcl::PointCloud<PointInT> &cloud, const pcl::PointCloud<PointNT> &normals,
00184 const std::vector<int> &indices, int nr_split, Eigen::VectorXf &pfh_histogram);
00185
00186 protected:
00192 void
00193 computeFeature (PointCloudOut &output);
00194
00196 int nr_subdiv_;
00197
00199 Eigen::VectorXf pfh_histogram_;
00200
00202 Eigen::Vector4f pfh_tuple_;
00203
00205 int f_index_[3];
00206
00208 float d_pi_;
00209
00211 std::map<std::pair<int, int>, Eigen::Vector4f, std::less<std::pair<int, int> >, Eigen::aligned_allocator<Eigen::Vector4f> > feature_map_;
00212
00214 std::queue<std::pair<int, int> > key_list_;
00215
00217 unsigned int max_cache_size_;
00218
00220 bool use_cache_;
00221 };
00222 }
00223
00224 #ifdef PCL_NO_PRECOMPILE
00225 #include <pcl/features/impl/pfh.hpp>
00226 #endif
00227
00228 #endif //#ifndef PCL_PFH_H_
00229