Point Cloud Library (PCL)
1.7.0
|
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 00012 /** \brief @b PointCoherence is a base class to compute coherence between the two points. 00013 * \author Ryohei Ueda 00014 * \ingroup tracking 00015 */ 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: 00024 /** \brief empty constructor */ 00025 PointCoherence () : coherence_name_ () {} 00026 00027 /** \brief empty distructor */ 00028 virtual ~PointCoherence () {} 00029 00030 /** \brief compute coherence from the source point to the target point. 00031 * \param source instance of source point. 00032 * \param target instance of target point. 00033 */ 00034 inline double 00035 compute (PointInT &source, PointInT &target); 00036 00037 protected: 00038 00039 /** \brief The coherence name. */ 00040 std::string coherence_name_; 00041 00042 /** \brief abstract method to calculate coherence. 00043 * \param[in] source instance of source point. 00044 * \param[in] target instance of target point. 00045 */ 00046 virtual double 00047 computeCoherence (PointInT &source, PointInT &target) = 0; 00048 00049 /** \brief Get a string representation of the name of this class. */ 00050 inline const std::string& 00051 getClassName () const { return (coherence_name_); } 00052 00053 }; 00054 00055 /** \brief @b PointCloudCoherence is a base class to compute coherence between the two PointClouds. 00056 * \author Ryohei Ueda 00057 * \ingroup tracking 00058 */ 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; 00071 /** \brief Constructor. */ 00072 PointCloudCoherence () : coherence_name_ (), target_input_ (), point_coherences_ () {} 00073 00074 /** \brief Destructor. */ 00075 virtual ~PointCloudCoherence () {} 00076 00077 /** \brief compute coherence between two pointclouds. */ 00078 inline void 00079 compute (const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices, 00080 float &w_i); 00081 00082 /** \brief get a list of pcl::tracking::PointCoherence.*/ 00083 inline std::vector<PointCoherencePtr> 00084 getPointCoherences () { return point_coherences_; } 00085 00086 /** \brief set a list of pcl::tracking::PointCoherence. 00087 * \param coherences a list of pcl::tracking::PointCoherence. 00088 */ 00089 inline void 00090 setPointCoherences (std::vector<PointCoherencePtr> coherences) { point_coherences_ = coherences; } 00091 00092 /** \brief This method should get called before starting the actual computation. */ 00093 virtual bool initCompute (); 00094 00095 /** \brief add a PointCoherence to the PointCloudCoherence. 00096 * \param coherence a pointer to PointCoherence. 00097 */ 00098 inline void 00099 addPointCoherence (PointCoherencePtr coherence) { point_coherences_.push_back (coherence); } 00100 00101 /** \brief add a PointCoherence to the PointCloudCoherence. 00102 * \param coherence a pointer to PointCoherence. 00103 */ 00104 virtual inline void 00105 setTargetCloud (const PointCloudInConstPtr &cloud) { target_input_ = cloud; } 00106 00107 protected: 00108 /** \brief Abstract method to compute coherence. */ 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 00114 /** \brief Get a string representation of the name of this class. */ 00115 inline const std::string& 00116 getClassName () const { return (coherence_name_); } 00117 00118 00119 /** \brief The coherence name. */ 00120 std::string coherence_name_; 00121 00122 /** \brief a pointer to target point cloud*/ 00123 PointCloudInConstPtr target_input_; 00124 00125 /** \brief a list of pointers to PointCoherence.*/ 00126 std::vector<PointCoherencePtr> point_coherences_; 00127 }; 00128 00129 } 00130 } 00131 00132 00133 #include <pcl/tracking/impl/coherence.hpp> 00134 00135 00136 #endif