modified_icp.hpp
Go to the documentation of this file.
00001 
00064 #pragma once
00065 
00066 #include <pcl/registration/icp.h>
00067 #include <pcl/kdtree/kdtree.h>
00068 #include "../feature_container.h"
00069 #ifdef PCL_VERSION_COMPARE
00070   #include <pcl/registration/registration.h>
00071   #include <pcl/features/feature.h>
00072   #include <pcl/search/kdtree.h>
00073   #include <pcl/search/search.h>
00074 #endif
00075 #ifdef GICP_ENABLE
00076 #include <pcl/registration/gicp.h>
00077 #include <pcl/registration/transformation_estimation_lm.h>
00078 #endif
00079 
00084 class ModifiedICP_G {
00085 public:
00086   virtual void setLM()=0;
00087   virtual void setSearchFeatures(FeatureContainerInterface* features)=0;
00088 };
00089 
00093 template <typename ParentClass, typename PointT>
00094 class ModifiedICP_T : public ParentClass, public ModifiedICP_G {
00095   const FeatureContainerInterface* features_;
00096 
00100   template <typename PointT2>
00101   #ifdef PCL_VERSION_COMPARE
00102     #if PCL_MINOR_VERSION > 6 // not tested with pcl 1.4 yet
00103       class FeatureSearch: public pcl::search::KdTree<PointT2>
00104     #else
00105       class FeatureSearch: public pcl::KdTreeFLANN<PointT2>
00106     #endif
00107   #else
00108     class FeatureSearch : public pcl::KdTree<PointT2>
00109   #endif
00110   {
00111     FeatureContainerInterface* features_;
00112 
00113     void error() const {ROS_ERROR("unsupported");}
00114 
00115   public:
00116     FeatureSearch(FeatureContainerInterface* features):
00117       features_(features)
00118       { }
00119 
00121     virtual int
00122     nearestKSearch (const pcl::PointCloud<PointT2> &cloud, int index, int k, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
00123     {
00124       features_->findFeatureCorrespondences (index, k_indices, k_sqr_distances);
00125       return k_indices.size();
00126     }
00127 
00129     virtual int
00130     nearestKSearch (const PointT2 &p_q, int k, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances) {error();return 0;}
00131 
00133     virtual int
00134     nearestKSearch (int index, int k, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances) {error();return 0;}
00135 
00137     virtual int
00138     radiusSearch (const pcl::PointCloud<PointT2> &cloud, int index, double radius, std::vector<int> &k_indices,
00139                   std::vector<float> &k_sqr_distances, int max_nn = INT_MAX) const {error();return 0;}
00140 
00142     virtual int
00143     radiusSearch (const PointT2 &p_q, double radius, std::vector<int> &k_indices,
00144                   std::vector<float> &k_sqr_distances, int max_nn = INT_MAX) const {error();return 0;}
00145 
00147     virtual int
00148     radiusSearch (int index, double radius, std::vector<int> &k_indices,
00149                   std::vector<float> &k_sqr_distances, int max_nn = INT_MAX) const {error();return 0;}
00150 
00151     #if PCL_MINOR_VERSION > 6
00152     virtual const std::string& getName() const {return "ICP Feature";}
00153     #else
00154     virtual std::string getName() const {return "ICP Feature";}
00155     #endif
00156 
00157   };
00158 
00159   public:
00160 
00162   int getNeededIterations() {return this->nr_iterations_;}
00163 
00165   void setLM() {
00166 #ifdef GICP_ENABLE
00167     this->min_number_correspondences_ = 4;
00168     this->reg_name_ = "IterativeClosestPointNonLinear";
00169 
00170     this->transformation_estimation_.reset (new pcl::registration::TransformationEstimationLM<PointT, PointT>);
00171 #endif
00172   }
00173 
00175   void setSearchFeatures(FeatureContainerInterface* features) {
00176     this->features_ = features;
00177     //this->tree_.reset( static_cast<typename FeatureSearch<PointT>::BaseSearch*>(new FeatureSearch<PointT>(features)) );
00178     this->tree_.reset( new FeatureSearch<PointT>(features) );
00179   }
00180 
00181 };
00182 
00186 template <class PointT>
00187 class ModifiedICP : public ModifiedICP_T<pcl::IterativeClosestPoint<PointT,PointT>, PointT>
00188 {
00189 };
00190 
00191 
00192 #ifdef GICP_ENABLE
00193 
00197 template <class PointT>
00198 class ModifiedGICP : public pcl::GeneralizedIterativeClosestPoint<PointT,PointT>, public ModifiedICP_G
00199 {
00200   public:
00201   int getNeededIterations() {return 1;} //dummy
00202 
00203   void setLM() {
00204     std::cerr<<"ERROR: not supported\n";
00205   }
00206 
00207   void setSearchFeatures(FeatureContainerInterface* features) {
00208     std::cerr<<"ERROR: not supported\n";
00209   }
00210 };
00211 #endif
00212 


cob_3d_registration
Author(s): Joshua Hampp
autogenerated on Wed Aug 26 2015 11:02:36