registration_correspondence.h
Go to the documentation of this file.
00001 
00064 #ifndef REGISTRATION_CORRESPONDENCE_H_
00065 #define REGISTRATION_CORRESPONDENCE_H_
00066 #ifdef PCL_VERSION_COMPARE
00067   #include <pcl/correspondence.h>
00068 #endif
00069 #include <pcl/registration/correspondence_estimation.h>
00070 #include <pcl/registration/correspondence_rejection_distance.h>
00071 #include <pcl/registration/transformation_estimation_svd.h>
00072 
00073 namespace cob_3d_registration {
00074 
00075 template <typename Point>
00076 class RegKeypointCorrespondenceAbstract
00077 {
00078 public:
00079   virtual boost::shared_ptr<pcl::PointCloud<Point> > getSourcePoints()=0;
00080   virtual boost::shared_ptr<pcl::PointCloud<Point> > getTargetPoints()=0;
00081 
00082   #ifdef PCL_VERSION_COMPARE
00083     virtual void getCorrespondences(pcl::Correspondences &correspondences)=0;
00084   #else
00085     virtual void getCorrespondences(std::vector<pcl::registration::Correspondence> &correspondences)=0;
00086   #endif
00087 
00088   virtual bool compute(const pcl::PointCloud<Point> &src, const pcl::PointCloud<Point> &tgt)=0;
00089 };
00090 
00091 template <typename Point, typename Keypoint>
00092 class RegKeypointCorrespondence : public RegKeypointCorrespondenceAbstract<Point>
00093 {
00094 protected:
00095   pcl::PointCloud<Keypoint> keypoints_src_, keypoints_tgt_;
00096 
00097   virtual Point getPointForKeypointSrc(const int ind)=0;
00098   virtual Point getPointForKeypointTgt(const int ind)=0;
00099 
00100 public:
00101   #ifdef PCL_VERSION_COMPARE
00102     virtual void getCorrespondences(pcl::Correspondences &correspondences) {
00103   #else
00104     virtual void getCorrespondences(std::vector<pcl::registration::Correspondence> &correspondences) {
00105   #endif
00106     pcl::registration::CorrespondenceEstimation<Keypoint, Keypoint> est;
00107     est.setInputCloud (keypoints_src_.makeShared());
00108     est.setInputTarget (keypoints_tgt_.makeShared());
00109     est.determineReciprocalCorrespondences (correspondences);
00110   }
00111 
00112   virtual boost::shared_ptr<pcl::PointCloud<Point> > getSourcePoints() {
00113     boost::shared_ptr<pcl::PointCloud<Point> > ret(new pcl::PointCloud<Point>);
00114     for(int i=0; i<(int)keypoints_src_.size(); i++)
00115       ret->points.push_back(getPointForKeypointSrc(i));
00116     ret->height=1;
00117     ret->width=ret->size();
00118     return ret;
00119   }
00120 
00121   virtual boost::shared_ptr<pcl::PointCloud<Point> > getTargetPoints() {
00122     boost::shared_ptr<pcl::PointCloud<Point> > ret(new pcl::PointCloud<Point>);
00123     for(int i=0; i<(int)keypoints_tgt_.size(); i++)
00124       ret->points.push_back(getPointForKeypointTgt(i));
00125     ret->height=1;
00126     ret->width=ret->size();
00127     return ret;
00128   }
00129 };
00130 
00131 
00132 template <typename Point>
00133 class Registration_Corrospondence : public GeneralRegistration<Point>
00134 {
00135 public:
00136   Registration_Corrospondence():
00137     rejection_dis_(0.5), keypoints_(NULL)
00138   {}
00139 
00140   void setKeypoints(RegKeypointCorrespondenceAbstract<Point> *k) {keypoints_=k;}
00141   RegKeypointCorrespondenceAbstract<Point> *getKeypoints() {return keypoints_;}
00142 
00143 protected:
00144 
00145   virtual bool compute_features();
00146   virtual bool compute_corrospondences();
00147   virtual bool compute_transformation();
00148 
00149   #ifdef PCL_VERSION_COMPARE
00150     void rejectBadCorrespondences (const pcl::CorrespondencesPtr &all_correspondences,
00151                                  pcl::Correspondences &remaining_correspondences);
00152   #else
00153     void rejectBadCorrespondences (const pcl::registration::CorrespondencesPtr &all_correspondences,
00154                                  pcl::registration::Correspondences &remaining_correspondences);
00155   #endif
00156 
00157   //internal states
00158   pcl::PointCloud<Point> register_;
00159 
00160   float rejection_dis_;
00161 
00162   RegKeypointCorrespondenceAbstract<Point> *keypoints_;
00163   #ifdef PCL_VERSION_COMPARE
00164     pcl::CorrespondencesPtr all_correspondences_;
00165   #else
00166     pcl::registration::CorrespondencesPtr all_correspondences_;
00167   #endif
00168 };
00169 
00170 }
00171 
00172 //keypoints...
00173 //#include "features/segments.h"
00174 #include "features/narf_kp.h"
00175 
00176 #endif /* REGISTRATION_CORRESPONDENCE_H_ */


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