Point Cloud Library (PCL)  1.7.1
coherence.h
1 #ifndef PCL_TRACKING_COHERENCE_H_
2 #define PCL_TRACKING_COHERENCE_H_
3 
4 #include <pcl/pcl_base.h>
5 
6 namespace pcl
7 {
8 
9  namespace tracking
10  {
11 
12  /** \brief @b PointCoherence is a base class to compute coherence between the two points.
13  * \author Ryohei Ueda
14  * \ingroup tracking
15  */
16  template <typename PointInT>
18  {
19  public:
20  typedef boost::shared_ptr< PointCoherence<PointInT> > Ptr;
21  typedef boost::shared_ptr< const PointCoherence<PointInT> > ConstPtr;
22 
23  public:
24  /** \brief empty constructor */
26 
27  /** \brief empty distructor */
28  virtual ~PointCoherence () {}
29 
30  /** \brief compute coherence from the source point to the target point.
31  * \param source instance of source point.
32  * \param target instance of target point.
33  */
34  inline double
35  compute (PointInT &source, PointInT &target);
36 
37  protected:
38 
39  /** \brief The coherence name. */
40  std::string coherence_name_;
41 
42  /** \brief abstract method to calculate coherence.
43  * \param[in] source instance of source point.
44  * \param[in] target instance of target point.
45  */
46  virtual double
47  computeCoherence (PointInT &source, PointInT &target) = 0;
48 
49  /** \brief Get a string representation of the name of this class. */
50  inline const std::string&
51  getClassName () const { return (coherence_name_); }
52 
53  };
54 
55  /** \brief @b PointCloudCoherence is a base class to compute coherence between the two PointClouds.
56  * \author Ryohei Ueda
57  * \ingroup tracking
58  */
59  template <typename PointInT>
61  {
62  public:
63  typedef boost::shared_ptr< PointCloudCoherence<PointInT> > Ptr;
64  typedef boost::shared_ptr< const PointCloudCoherence<PointInT> > ConstPtr;
65 
69 
71  /** \brief Constructor. */
73 
74  /** \brief Destructor. */
75  virtual ~PointCloudCoherence () {}
76 
77  /** \brief compute coherence between two pointclouds. */
78  inline void
79  compute (const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices,
80  float &w_i);
81 
82  /** \brief get a list of pcl::tracking::PointCoherence.*/
83  inline std::vector<PointCoherencePtr>
85 
86  /** \brief set a list of pcl::tracking::PointCoherence.
87  * \param coherences a list of pcl::tracking::PointCoherence.
88  */
89  inline void
90  setPointCoherences (std::vector<PointCoherencePtr> coherences) { point_coherences_ = coherences; }
91 
92  /** \brief This method should get called before starting the actual computation. */
93  virtual bool initCompute ();
94 
95  /** \brief add a PointCoherence to the PointCloudCoherence.
96  * \param coherence a pointer to PointCoherence.
97  */
98  inline void
99  addPointCoherence (PointCoherencePtr coherence) { point_coherences_.push_back (coherence); }
100 
101  /** \brief add a PointCoherence to the PointCloudCoherence.
102  * \param coherence a pointer to PointCoherence.
103  */
104  virtual inline void
106 
107  protected:
108  /** \brief Abstract method to compute coherence. */
109  virtual void
110  computeCoherence (const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices, float &w_j) = 0;
111 
112  inline double calcPointCoherence (PointInT &source, PointInT &target);
113 
114  /** \brief Get a string representation of the name of this class. */
115  inline const std::string&
116  getClassName () const { return (coherence_name_); }
117 
118 
119  /** \brief The coherence name. */
120  std::string coherence_name_;
121 
122  /** \brief a pointer to target point cloud*/
124 
125  /** \brief a list of pointers to PointCoherence.*/
126  std::vector<PointCoherencePtr> point_coherences_;
127  };
128 
129  }
130 }
131 
132 
133 #include <pcl/tracking/impl/coherence.hpp>
134 
135 
136 #endif