00001 #ifndef PCL_TRACKING_COHERENCE_H_ 00002 #define PCL_TRACKING_COHERENCE_H_ 00003 00004 #include <pcl/pcl_base.h> 00005 00006 namespace pcl 00007 { 00008 00009 namespace tracking 00010 { 00011 00016 template <typename PointInT> 00017 class PointCoherence 00018 { 00019 public: 00020 typedef boost::shared_ptr< PointCoherence<PointInT> > Ptr; 00021 typedef boost::shared_ptr< const PointCoherence<PointInT> > ConstPtr; 00022 00023 public: 00025 PointCoherence () : coherence_name_ () {} 00026 00028 virtual ~PointCoherence () {} 00029 00034 inline double 00035 compute (PointInT &source, PointInT &target); 00036 00037 protected: 00038 00040 std::string coherence_name_; 00041 00046 virtual double 00047 computeCoherence (PointInT &source, PointInT &target) = 0; 00048 00050 inline const std::string& 00051 getClassName () const { return (coherence_name_); } 00052 00053 }; 00054 00059 template <typename PointInT> 00060 class PointCloudCoherence 00061 { 00062 public: 00063 typedef boost::shared_ptr< PointCloudCoherence<PointInT> > Ptr; 00064 typedef boost::shared_ptr< const PointCloudCoherence<PointInT> > ConstPtr; 00065 00066 typedef pcl::PointCloud<PointInT> PointCloudIn; 00067 typedef typename PointCloudIn::Ptr PointCloudInPtr; 00068 typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr; 00069 00070 typedef typename PointCoherence<PointInT>::Ptr PointCoherencePtr; 00072 PointCloudCoherence () : coherence_name_ (), target_input_ (), point_coherences_ () {} 00073 00075 virtual ~PointCloudCoherence () {} 00076 00078 inline void 00079 compute (const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices, 00080 float &w_i); 00081 00083 inline std::vector<PointCoherencePtr> 00084 getPointCoherences () { return point_coherences_; } 00085 00089 inline void 00090 setPointCoherences (std::vector<PointCoherencePtr> coherences) { point_coherences_ = coherences; } 00091 00093 virtual bool initCompute (); 00094 00098 inline void 00099 addPointCoherence (PointCoherencePtr coherence) { point_coherences_.push_back (coherence); } 00100 00104 virtual inline void 00105 setTargetCloud (const PointCloudInConstPtr &cloud) { target_input_ = cloud; } 00106 00107 protected: 00109 virtual void 00110 computeCoherence (const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices, float &w_j) = 0; 00111 00112 inline double calcPointCoherence (PointInT &source, PointInT &target); 00113 00115 inline const std::string& 00116 getClassName () const { return (coherence_name_); } 00117 00118 00120 std::string coherence_name_; 00121 00123 PointCloudInConstPtr target_input_; 00124 00126 std::vector<PointCoherencePtr> point_coherences_; 00127 }; 00128 00129 } 00130 } 00131 00132 00133 #include <pcl/tracking/impl/coherence.hpp> 00134 00135 00136 #endif