Point Cloud Library (PCL)  1.14.1-dev
nearest_pair_point_cloud_coherence.h
1 #pragma once
2 
3 #include <pcl/search/search.h>
4 #include <pcl/tracking/coherence.h>
5 
6 namespace pcl {
7 namespace tracking {
8 /** \brief @b NearestPairPointCloudCoherence computes coherence between two pointclouds
9  * using the nearest point pairs.
10  * \author Ryohei Ueda
11  * \ingroup tracking
12  */
13 template <typename PointInT>
15 : public PointCloudCoherence<PointInT> {
16 public:
20 
25 
26  using Ptr = shared_ptr<NearestPairPointCloudCoherence<PointInT>>;
27  using ConstPtr = shared_ptr<const NearestPairPointCloudCoherence<PointInT>>;
30 
31  /** \brief empty constructor */
33  {
34  coherence_name_ = "NearestPairPointCloudCoherence";
35  }
36 
37  /** \brief Provide a pointer to a dataset to add additional information
38  * to estimate the features for every point in the input dataset. This
39  * is optional, if this is not set, it will only use the data in the
40  * input cloud to estimate the features. This is useful when you only
41  * need to compute the features for a downsampled cloud.
42  * \param search a pointer to a PointCloud message
43  */
44  inline void
45  setSearchMethod(const SearchPtr& search)
46  {
47  search_ = search;
48  }
49 
50  /** \brief Get a pointer to the point cloud dataset. */
51  inline SearchPtr
53  {
54  return (search_);
55  }
56 
57  /** \brief add a PointCoherence to the PointCloudCoherence.
58  * \param[in] cloud coherence a pointer to PointCoherence.
59  */
60  inline void
61  setTargetCloud(const PointCloudInConstPtr& cloud) override
62  {
63  new_target_ = true;
65  }
66 
67  /** \brief set maximum distance to be taken into account.
68  * \param[in] val maximum distance.
69  */
70  inline void
71  setMaximumDistance(double val)
72  {
73  maximum_distance_ = val;
74  }
75 
76 protected:
78 
79  /** \brief This method should get called before starting the actual
80  * computation. */
81  bool
82  initCompute() override;
83 
84  /** \brief A flag which is true if target_input_ is updated */
85  bool new_target_{false};
86 
87  /** \brief A pointer to the spatial search object. */
88  SearchPtr search_{nullptr};
89 
90  /** \brief max of distance for points to be taken into account*/
91  double maximum_distance_{std::numeric_limits<double>::max()};
92 
93  /** \brief compute the nearest pairs and compute coherence using
94  * point_coherences_ */
95  void
96  computeCoherence(const PointCloudInConstPtr& cloud,
97  const IndicesConstPtr& indices,
98  float& w_j) override;
99 };
100 } // namespace tracking
101 } // namespace pcl
102 
103 // #include <pcl/tracking/impl/nearest_pair_point_cloud_coherence.hpp>
104 #ifdef PCL_NO_PRECOMPILE
105 #include <pcl/tracking/impl/nearest_pair_point_cloud_coherence.hpp>
106 #endif
shared_ptr< const pcl::search::Search< PointT > > ConstPtr
Definition: search.h:82
shared_ptr< pcl::search::Search< PointT > > Ptr
Definition: search.h:81
NearestPairPointCloudCoherence computes coherence between two pointclouds using the nearest point pai...
typename pcl::search::Search< PointInT >::ConstPtr SearchConstPtr
void setMaximumDistance(double val)
set maximum distance to be taken into account.
void setTargetCloud(const PointCloudInConstPtr &cloud) override
add a PointCoherence to the PointCloudCoherence.
SearchPtr getSearchMethod()
Get a pointer to the point cloud dataset.
typename pcl::search::Search< PointInT >::Ptr SearchPtr
void setSearchMethod(const SearchPtr &search)
Provide a pointer to a dataset to add additional information to estimate the features for every point...
PointCloudCoherence is a base class to compute coherence between the two PointClouds.
Definition: coherence.h:59
typename PointCloudIn::ConstPtr PointCloudInConstPtr
Definition: coherence.h:66
typename PointCoherence< PointInT >::Ptr PointCoherencePtr
Definition: coherence.h:68
virtual void setTargetCloud(const PointCloudInConstPtr &cloud)
add a PointCoherence to the PointCloudCoherence.
Definition: coherence.h:115
shared_ptr< PointCloudCoherence< PointInT > > Ptr
Definition: coherence.h:61
shared_ptr< const PointCloudCoherence< PointInT > > ConstPtr
Definition: coherence.h:62
shared_ptr< const Indices > IndicesConstPtr
Definition: pcl_base.h:59
#define PCL_EXPORTS
Definition: pcl_macros.h:323