organized_features.h
Go to the documentation of this file.
00001 
00063 #ifndef __ORGANIZED_FEATURES_H__
00064 #define __ORGANIZED_FEATURES_H__
00065 
00066 #include <pcl/pcl_base.h>
00067 #include <pcl/console/print.h>
00068 
00069 namespace cob_3d_features
00070 {
00071   template <typename PointInT, typename PointOutT>
00072     class OrganizedFeatures : public pcl::PCLBase<PointInT>
00073   {
00074     public:
00075 
00076       using pcl::PCLBase<PointInT>::input_;
00077       using pcl::PCLBase<PointInT>::indices_;
00078 
00079       typedef pcl::PointCloud<PointInT> PointCloudIn;
00080       typedef typename PointCloudIn::Ptr PointCloudInPtr;
00081       typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr;
00082 
00083       typedef pcl::PointCloud<PointOutT> PointCloudOut;
00084 
00085     public:
00087       OrganizedFeatures () : pixel_search_radius_(2)
00088         ,pixel_steps_(1)
00089         ,circle_steps_(1)
00090         ,mask_()
00091         ,n_points_(0)
00092         ,inv_width_(0.0)
00093         ,skip_distant_point_threshold_(4.0)
00094         ,fake_surface_(true)
00095         ,mask_changed_(false)
00096       { };
00097 
00098       inline void
00099         setSearchSurface(const PointCloudInConstPtr cloud)
00100       {
00101         surface_ = cloud;
00102         fake_surface_ = false;
00103       }
00104 
00105       inline void
00106         setPixelWindowSize(int size, int pixel_steps=1, int circle_steps=1)
00107       {
00108         pixel_search_radius_ = size / 2;
00109         pixel_steps_ = pixel_steps;
00110         circle_steps_ = circle_steps;
00111         mask_changed_ = true;
00112       }
00113 
00114       inline void
00115         setPixelSearchRadius(int pixel_radius, int pixel_steps=1, int circle_steps=1)
00116       {
00117         pixel_search_radius_ = pixel_radius;
00118         pixel_steps_ = pixel_steps;
00119         circle_steps_ = circle_steps;
00120         mask_changed_ = true;
00121       }
00122 
00123       // Ignore points in window with high distance
00124       // Value represents the quantization steps of Kinect (approximately)
00125       inline void
00126         setSkipDistantPointThreshold(float th)
00127       {
00128         skip_distant_point_threshold_ = th;
00129       }
00130 
00131       void compute(PointCloudOut &output);
00132 
00133       int searchForNeighbors(int index, std::vector<int>& indices);
00134 
00135       int searchForNeighborsInRange(int index, std::vector<int>& indices);
00136 
00137       int searchForNeighborsInRange(int index, std::vector<int>& indices, std::vector<float>& sqr_distances);
00138 
00139       void computeMaskManually(int cloud_width);
00140 
00141 
00142     protected:
00143 
00144       virtual inline bool
00145         initCompute();
00146 
00147       virtual inline bool
00148         deinitCompute();
00149 
00150       inline bool
00151         isInRange (const PointInT &pi, const PointInT &pq, float distance_th_sqr)
00152       {
00153         float dx = pi.x - pq.x;
00154         float dy = pi.y - pq.y;
00155         float dz = pi.z - pq.z;
00156         return ( (dx*dx + dy*dy + dz*dz) < distance_th_sqr);
00157       }
00158 
00159       inline bool
00160         isInImage (int u, int v)
00161       {
00162         return ( v >= 0 && v < (int)input_->height && u >= 0 && u < (int)input_->width );
00163       }
00164 
00165       inline const std::string&
00166         getClassName () const { return (feature_name_); }
00167 
00168       PointCloudInConstPtr surface_;
00169 
00170       int pixel_search_radius_;
00171       int pixel_steps_;
00172       int circle_steps_;
00173       std::vector<std::vector<int> > mask_;
00174       int n_points_;
00175       float inv_width_;
00176       float skip_distant_point_threshold_;
00177 
00178       bool fake_surface_;
00179       bool mask_changed_;
00180 
00181       std::string feature_name_;
00182 
00183     private:
00184       virtual void
00185         computeFeature (PointCloudOut &output) = 0;
00186   };
00187 }
00188 
00189 #include "cob_3d_features/impl/organized_features.hpp"
00190 
00191 #endif  //#ifndef __ORGANIZED_FEATURES_H__


cob_3d_features
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:02:26