narf.h
Go to the documentation of this file.
00001 
00059 /*
00060  * narf.h
00061  *
00062  *  Created on: Nov 15, 2011
00063  *      Author: goa-jh
00064  */
00065 
00066 #ifndef NARF_H_
00067 #define NARF_H_
00068 
00069 #include "pcl/range_image/range_image.h"
00070 #include "pcl/features/range_image_border_extractor.h"
00071 #include "pcl/keypoints/narf_keypoint.h"
00072 #include "pcl/features/narf_descriptor.h"
00073 #include <pcl/filters/extract_indices.h>
00074 
00075 
00076 template<typename Point>
00077 class Feature_NARF : public FeatureContainerInterface_Euclidean<Point>
00078 {
00079   pcl::PointCloud<pcl::Narf36> feature_in_, feature_out_;
00080 
00081 public:
00082   static void extractFeatures(const pcl::PointCloud<Point>& point_cloud, pcl::PointCloud<pcl::Narf36> &narf_descriptors);
00083 
00084   const pcl::PointCloud<Point> &getFilteredInputCloud() {return this->org_in_;}
00085   const pcl::PointCloud<Point> &getFilteredOutputCloud() {return this->org_out_;}
00086 
00087   virtual bool hidden_build() {
00088 
00089     ROS_INFO("calc narf for source %d", (int)this->org_in_.size());
00090     {
00091       extractFeatures(this->org_in_, feature_in_);
00092       this->org_in_.points.clear();
00093       for(int i=0; i<(int)feature_in_.size(); i++) {
00094         Point p;
00095         memset(&p,0,sizeof(Point));
00096         p.x=feature_in_.points[i].x;
00097         p.y=feature_in_.points[i].y;
00098         p.z=feature_in_.points[i].z;
00099         this->org_in_.points.push_back(p);
00100       }
00101       this->org_in_.height=1;
00102       this->org_in_.width=this->org_in_.size();
00103     }
00104 
00105     ROS_INFO("calc narf for target %d", (int)this->org_out_.size());
00106     {
00107       extractFeatures(this->org_out_, feature_out_);
00108       this->org_out_.points.clear();
00109       for(int i=0; i<(int)feature_out_.size(); i++) {
00110         Point p;
00111         memset(&p,0,sizeof(Point));
00112         p.x=feature_out_.points[i].x;
00113         p.y=feature_out_.points[i].y;
00114         p.z=feature_out_.points[i].z;
00115         this->org_out_.points.push_back(p);
00116       }
00117       this->org_out_.height=1;
00118       this->org_out_.width=this->org_out_.size();
00119     }
00120 
00121     //need to rebuild tree
00122     //ROS_INFO("build tree %d %d", this->org_in_.size(), this->org_out_.size());
00123 #ifdef PCL_VERSION_COMPARE
00124     this->tree_.reset (new pcl::search::KdTree<Point>);
00125 #else
00126         this->tree_.reset (new pcl::KdTreeFLANN<Point>);
00127 #endif
00128     this->tree_->setInputCloud(this->org_in_.makeShared());
00129     //ROS_INFO("build tree done");
00130 
00131     return true;
00132   }
00133 
00134   virtual Eigen::VectorXf getFeatureOut(const int index) {
00135     Eigen::VectorXf b;
00136     b.resize(36);
00137     for(int i=0; i<36; i++) b(i) = feature_out_.points[index].descriptor[i];
00138     return b;
00139   }
00140   virtual Eigen::VectorXf getFeatureIn(const int index) {
00141     Eigen::VectorXf b;
00142     b.resize(36);
00143     for(int i=0; i<36; i++) b(i) = feature_in_.points[index].descriptor[i];
00144     return b;
00145   }
00146 };
00147 
00148 #include "impl/narf.hpp"
00149 
00150 #endif /* NARF_H_ */


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