registration_icp_edges.h
Go to the documentation of this file.
00001 
00059 /*
00060  * registration_edges.h
00061  *
00062  *  Created on: Nov 21, 2011
00063  *      Author: goa-jh
00064  */
00065 
00066 #ifndef REGISTRATION_EDGES_H_
00067 #define REGISTRATION_EDGES_H_
00068 
00069 
00070 #include "registration_icp.h"
00071 #include "features/edges.h"
00072 
00073 #include <pcl/visualization/cloud_viewer.h>
00074 #include <pcl/filters/passthrough.h>
00075 
00076 namespace cob_3d_registration {
00077 
00078 template <typename Point>
00079 class Registration_ICP_Edges : public Registration_ICP_Features<Point>
00080 {
00081   Feature_Edges<Point> *mom_;
00082   pcl::PointCloud<Point> tmp_input_;
00083   bool first_;
00084 
00085 public:
00086   Registration_ICP_Edges():
00087     mom_(new Feature_Edges<Point>), first_(true)
00088   {
00089     this->setCorrDist(0.1);
00090     this->setFeatures(mom_);
00091   }
00092 
00093   virtual ~Registration_ICP_Edges() {
00094     delete mom_;
00095   }
00096 
00097   virtual boost::shared_ptr<const pcl::PointCloud<Point> > getMarkers() {
00098     boost::shared_ptr<pcl::PointCloud<Point> > r(new pcl::PointCloud<Point>);
00099     //*r=*this->input_;
00100     //*r+=this->register_;
00101     *r=this->register_;
00102     return r;
00103   }
00104 
00105   void setRadius(float v) {mom_->setRadius(v);}
00106   void setThreshold(float v) {mom_->setThreshold(v);}
00107   void setDisThreshold(float v) {mom_->setDisThreshold(v);}
00108 
00109 protected:
00110   virtual bool compute_features() {
00111     //save input first
00112     tmp_input_ = *this->input_org_;
00113 
00114     mom_->setSearchRadius(this->icp_max_corr_dist_);
00115     mom_->build(this->register_, *this->input_org_);
00116 
00117     return true;
00118   }
00119 
00120   virtual bool compute_transformation() {
00121     ROS_INFO("compute_transformation");
00122     bool b=false;
00123 
00124     if(first_) {
00125       this->register_ = mom_->getFilteredOutputCloud();
00126       b=true;
00127       first_=false;
00128       return b;
00129     }
00130 
00131     pcl::PointCloud<Point> tmp = this->register_,tmp2;
00132 
00133     //replace input cloud...
00134     this->register_= mom_->getFilteredInputCloud();
00135     this->input_  = mom_->getFilteredOutputCloud().makeShared();
00136 
00137     if(this->register_.size()>2&&this->input_->size()>2) {
00138 
00139       /*pcl::PassThrough<Point> pass;
00140       pass.setInputCloud (this->register_.makeShared());
00141       pass.setFilterFieldName ("z");
00142       pass.setFilterLimits (0.0, 6.0);
00143       pass.filter (this->register_);
00144       pass.setInputCloud (this->input_);
00145       pass.setFilterFieldName ("z");
00146       pass.setFilterLimits (0.2, 6.0);
00147       pass.filter (tmp2);
00148       this->input_  = tmp2.makeShared();*/
00149 
00150       /*DEBUGGING*/
00151       /*for(int i=1389; i<std::min((int)this->register_.size(),1390); i++)
00152         std::cout<<this->register_[i]<<" ";
00153       for(int i=1389; i<std::min((int)this->input_->size(),1390); i++)
00154         std::cout<<(*this->input_)[i]<<" ";
00155       {pcl::visualization::CloudViewer viewer("Cloud Viewer");
00156 
00157       viewer.showCloud(this->register_.makeShared(),"a");
00158 
00159       while (!viewer.wasStopped ())
00160       {
00161       }
00162       }
00163       {pcl::visualization::CloudViewer viewer("Cloud Viewer");
00164 
00165       viewer.showCloud(this->input_,"b");
00166 
00167       while (!viewer.wasStopped ())
00168       {
00169       }
00170       }*/
00171       /*END*/
00172 
00173       b=Registration_ICP_Features<Point>::compute_transformation();
00174 
00175       this->register_ = tmp;
00176       if(b) {
00177         //pcl::transformPointCloud(tmp_input_, tmp_input_, this->transformation_);
00178         this->register_ = mom_->getFilteredOutputCloud();
00179       }
00180 
00181     }
00182 
00183     ROS_INFO("done");
00184     return b;
00185   }
00186 };
00187 
00188 }
00189 
00190 #endif /* REGISTRATION_EDGES_H_ */


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