Point Cloud Library (PCL)  1.7.1
correspondence_estimation_backprojection.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id$
37  *
38  */
39 
40 #ifndef PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_H_
41 #define PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_H_
42 
43 #include <pcl/registration/correspondence_types.h>
44 #include <pcl/registration/correspondence_estimation.h>
45 
46 namespace pcl
47 {
48  namespace registration
49  {
50  /** \brief @b CorrespondenceEstimationBackprojection computes
51  * correspondences as points in the target cloud which have minimum
52  * \author Suat Gedikli
53  * \ingroup registration
54  */
55  template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar = float>
56  class CorrespondenceEstimationBackProjection : public CorrespondenceEstimationBase <PointSource, PointTarget, Scalar>
57  {
58  public:
59  typedef boost::shared_ptr<CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar> > Ptr;
60  typedef boost::shared_ptr<const CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar> > ConstPtr;
61 
71 
74 
78 
82 
86 
87  /** \brief Empty constructor.
88  *
89  * \note
90  * Sets the number of neighbors to be considered in the target point cloud (k_) to 10.
91  */
93  : source_normals_ ()
94  , source_normals_transformed_ ()
95  , target_normals_ ()
96  , k_ (10)
97  {
98  corr_name_ = "CorrespondenceEstimationBackProjection";
99  }
100 
101  /** \brief Empty destructor */
103 
104  /** \brief Set the normals computed on the source point cloud
105  * \param[in] normals the normals computed for the source cloud
106  */
107  inline void
108  setSourceNormals (const NormalsConstPtr &normals) { source_normals_ = normals; }
109 
110  /** \brief Get the normals of the source point cloud
111  */
112  inline NormalsConstPtr
113  getSourceNormals () const { return (source_normals_); }
114 
115  /** \brief Set the normals computed on the target point cloud
116  * \param[in] normals the normals computed for the target cloud
117  */
118  inline void
119  setTargetNormals (const NormalsConstPtr &normals) { target_normals_ = normals; }
120 
121  /** \brief Get the normals of the target point cloud
122  */
123  inline NormalsConstPtr
124  getTargetNormals () const { return (target_normals_); }
125 
126  /** \brief Determine the correspondences between input and target cloud.
127  * \param[out] correspondences the found correspondences (index of query point, index of target point, distance)
128  * \param[in] max_distance maximum distance between the normal on the source point cloud and the corresponding point in the target
129  * point cloud
130  */
131  void
133  double max_distance = std::numeric_limits<double>::max ());
134 
135  /** \brief Determine the reciprocal correspondences between input and target cloud.
136  * A correspondence is considered reciprocal if both Src_i has Tgt_i as a
137  * correspondence, and Tgt_i has Src_i as one.
138  *
139  * \param[out] correspondences the found correspondences (index of query and target point, distance)
140  * \param[in] max_distance maximum allowed distance between correspondences
141  */
142  virtual void
144  double max_distance = std::numeric_limits<double>::max ());
145 
146  /** \brief Set the number of nearest neighbours to be considered in the target
147  * point cloud. By default, we use k = 10 nearest neighbors.
148  *
149  * \param[in] k the number of nearest neighbours to be considered
150  */
151  inline void
152  setKSearch (unsigned int k) { k_ = k; }
153 
154  /** \brief Get the number of nearest neighbours considered in the target point
155  * cloud for computing correspondences. By default we use k = 10 nearest
156  * neighbors.
157  */
158  inline void
159  getKSearch () const { return (k_); }
160 
161  protected:
162 
167 
168  /** \brief Internal computation initalization. */
169  bool
170  initCompute ();
171 
172  private:
173 
174  /** \brief The normals computed at each point in the source cloud */
175  NormalsConstPtr source_normals_;
176 
177  /** \brief The normals computed at each point in the source cloud */
178  NormalsPtr source_normals_transformed_;
179 
180  /** \brief The normals computed at each point in the target cloud */
181  NormalsConstPtr target_normals_;
182 
183  /** \brief The number of neighbours to be considered in the target point cloud */
184  unsigned int k_;
185  };
186  }
187 }
188 
189 #include <pcl/registration/impl/correspondence_estimation_backprojection.hpp>
190 
191 #endif /* PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_H_ */
boost::shared_ptr< KdTree< PointT > > Ptr
Definition: kdtree.h:79
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
Abstract CorrespondenceEstimationBase class.
std::string corr_name_
The correspondence estimation method name.
void setTargetNormals(const NormalsConstPtr &normals)
Set the normals computed on the target point cloud.
void setKSearch(unsigned int k)
Set the number of nearest neighbours to be considered in the target point cloud.
CorrespondenceEstimationBackprojection computes correspondences as points in the target cloud which h...
PCL base class.
Definition: pcl_base.h:68
void setSourceNormals(const NormalsConstPtr &normals)
Set the normals computed on the source point cloud.
boost::shared_ptr< const PointCloud< PointSource > > ConstPtr
Definition: point_cloud.h:429
boost::shared_ptr< CorrespondenceEstimationBackProjection< PointSource, PointTarget, NormalT, Scalar > > Ptr
boost::shared_ptr< const CorrespondenceEstimationBackProjection< PointSource, PointTarget, NormalT, Scalar > > ConstPtr
NormalsConstPtr getTargetNormals() const
Get the normals of the target point cloud.
virtual void determineReciprocalCorrespondences(pcl::Correspondences &correspondences, double max_distance=std::numeric_limits< double >::max())
Determine the reciprocal correspondences between input and target cloud.
boost::shared_ptr< PointCloud< PointSource > > Ptr
Definition: point_cloud.h:428
void determineCorrespondences(pcl::Correspondences &correspondences, double max_distance=std::numeric_limits< double >::max())
Determine the correspondences between input and target cloud.
NormalsConstPtr getSourceNormals() const
Get the normals of the source point cloud.
void getKSearch() const
Get the number of nearest neighbours considered in the target point cloud for computing correspondenc...