Point Cloud Library (PCL)  1.11.0
coherence.hpp
1 #ifndef PCL_TRACKING_IMPL_COHERENCE_H_
2 #define PCL_TRACKING_IMPL_COHERENCE_H_
3 
4 #include <pcl/console/print.h>
5 #include <pcl/tracking/coherence.h>
6 
7 namespace pcl
8 {
9  namespace tracking
10  {
11 
12  template <typename PointInT> double
13  PointCoherence<PointInT>::compute (PointInT &source, PointInT &target)
14  {
15  return computeCoherence (source, target);
16  }
17 
18  template <typename PointInT> double
19  PointCloudCoherence<PointInT>::calcPointCoherence (PointInT &source, PointInT &target)
20  {
21  double val = 0.0;
22  for (std::size_t i = 0; i < point_coherences_.size (); i++)
23  {
24  PointCoherencePtr coherence = point_coherences_[i];
25  double d = std::log(coherence->compute (source, target));
26  //double d = coherence->compute (source, target);
27  if (! std::isnan(d))
28  val += d;
29  else
30  PCL_WARN ("nan!\n");
31  }
32  return val;
33  }
34 
35  template <typename PointInT> bool
37  {
38  if (!target_input_ || target_input_->points.empty ())
39  {
40  PCL_ERROR ("[pcl::%s::compute] target_input_ is empty!\n", getClassName ().c_str ());
41  return false;
42  }
43 
44  return true;
45 
46  }
47 
48  template <typename PointInT> void
50  {
51  if (!initCompute ())
52  {
53  PCL_ERROR ("[pcl::%s::compute] Init failed.\n", getClassName ().c_str ());
54  return;
55  }
56  computeCoherence (cloud, indices, w);
57  }
58  }
59 }
60 
61 #endif
void compute(const PointCloudInConstPtr &cloud, const IndicesConstPtr &indices, float &w_i)
compute coherence between two pointclouds.
Definition: coherence.hpp:49
double calcPointCoherence(PointInT &source, PointInT &target)
Definition: coherence.hpp:19
double compute(PointInT &source, PointInT &target)
compute coherence from the source point to the target point.
Definition: coherence.hpp:13
shared_ptr< const Indices > IndicesConstPtr
Definition: pcl_base.h:62
typename PointCoherence< PointInT >::Ptr PointCoherencePtr
Definition: coherence.h:69
typename PointCloudIn::ConstPtr PointCloudInConstPtr
Definition: coherence.h:67
virtual bool initCompute()
This method should get called before starting the actual computation.
Definition: coherence.hpp:36