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