Go to the documentation of this file.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 #ifndef PCL_FILTERS_SAMPLING_SURFACE_NORMAL_H_
00039 #define PCL_FILTERS_SAMPLING_SURFACE_NORMAL_H_
00040
00041 #include <pcl/filters/filter.h>
00042 #include <time.h>
00043 #include <limits.h>
00044
00045 namespace pcl
00046 {
00054 template<typename PointT>
00055 class SamplingSurfaceNormal: public Filter<PointT>
00056 {
00057 using Filter<PointT>::filter_name_;
00058 using Filter<PointT>::getClassName;
00059 using Filter<PointT>::indices_;
00060 using Filter<PointT>::input_;
00061
00062 typedef typename Filter<PointT>::PointCloud PointCloud;
00063 typedef typename PointCloud::Ptr PointCloudPtr;
00064 typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00065
00066 typedef typename Eigen::Matrix<float, Eigen::Dynamic, 1> Vector;
00067
00068 public:
00069
00070 typedef boost::shared_ptr< SamplingSurfaceNormal<PointT> > Ptr;
00071 typedef boost::shared_ptr< const SamplingSurfaceNormal<PointT> > ConstPtr;
00072
00074 SamplingSurfaceNormal () :
00075 sample_ (10), seed_ (static_cast<unsigned int> (time (NULL))), ratio_ ()
00076 {
00077 filter_name_ = "SamplingSurfaceNormal";
00078 srand (seed_);
00079 }
00080
00084 inline void
00085 setSample (unsigned int sample)
00086 {
00087 sample_ = sample;
00088 }
00089
00091 inline unsigned int
00092 getSample () const
00093 {
00094 return (sample_);
00095 }
00096
00100 inline void
00101 setSeed (unsigned int seed)
00102 {
00103 seed_ = seed;
00104 srand (seed_);
00105 }
00106
00108 inline unsigned int
00109 getSeed () const
00110 {
00111 return (seed_);
00112 }
00113
00117 inline void
00118 setRatio (float ratio)
00119 {
00120 ratio_ = ratio;
00121 }
00122
00124 inline float
00125 getRatio () const
00126 {
00127 return ratio_;
00128 }
00129
00130 protected:
00131
00133 unsigned int sample_;
00135 unsigned int seed_;
00137 float ratio_;
00138
00142 void
00143 applyFilter (PointCloud &output);
00144
00145 private:
00146
00149 struct CompareDim
00150 {
00152 const int dim;
00154 const pcl::PointCloud <PointT>& cloud;
00155
00157 CompareDim (const int dim, const pcl::PointCloud <PointT>& cloud) : dim (dim), cloud (cloud)
00158 {
00159 }
00160
00162 bool
00163 operator () (const int& p0, const int& p1)
00164 {
00165 if (dim == 0)
00166 return (cloud.points[p0].x < cloud.points[p1].x);
00167 else if (dim == 1)
00168 return (cloud.points[p0].y < cloud.points[p1].y);
00169 else if (dim == 2)
00170 return (cloud.points[p0].z < cloud.points[p1].z);
00171 return (false);
00172 }
00173 };
00174
00180 void
00181 findXYZMaxMin (const PointCloud& cloud, Vector& max_vec, Vector& min_vec);
00182
00193 void
00194 partition (const PointCloud& cloud, const int first, const int last,
00195 const Vector min_values, const Vector max_values,
00196 std::vector<int>& indices, PointCloud& outcloud);
00197
00205 void
00206 samplePartition (const PointCloud& data, const int first, const int last,
00207 std::vector<int>& indices, PointCloud& outcloud);
00208
00214 float
00215 findCutVal (const PointCloud& cloud, const int cut_dim, const int cut_index);
00216
00223 void
00224 computeNormal (const PointCloud& cloud, Eigen::Vector4f &normal, float& curvature);
00225
00232 unsigned int
00233 computeMeanAndCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
00234 Eigen::Matrix3f &covariance_matrix,
00235 Eigen::Vector4f ¢roid);
00236
00243 void
00244 solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
00245 float &nx, float &ny, float &nz, float &curvature);
00246 };
00247 }
00248
00249 #ifdef PCL_NO_PRECOMPILE
00250 #include <pcl/filters/impl/sampling_surface_normal.hpp>
00251 #endif
00252
00253 #endif //#ifndef PCL_FILTERS_SAMPLING_SURFACE_NORMAL_H_