Point Cloud Library (PCL) 1.15.1-dev
Loading...
Searching...
No Matches
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#pragma once
41
42#include <pcl/registration/correspondence_estimation.h>
43#include <pcl/registration/correspondence_types.h>
44
45namespace pcl {
46namespace registration {
47/** \brief @b CorrespondenceEstimationBackprojection computes
48 * correspondences as points in the target cloud which have minimum
49 * \author Suat Gedikli
50 * \ingroup registration
51 */
52template <typename PointSource,
53 typename PointTarget,
54 typename NormalT,
55 typename Scalar = float>
57: public CorrespondenceEstimationBase<PointSource, PointTarget, Scalar> {
58public:
59 using Ptr = shared_ptr<CorrespondenceEstimationBackProjection<PointSource,
60 PointTarget,
61 NormalT,
62 Scalar>>;
63 using ConstPtr = shared_ptr<const CorrespondenceEstimationBackProjection<PointSource,
64 PointTarget,
65 NormalT,
66 Scalar>>;
67
68 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initCompute;
69 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::
71 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::
73 using PCLBase<PointSource>::deinitCompute;
74 using PCLBase<PointSource>::input_;
75 using PCLBase<PointSource>::indices_;
76 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::getClassName;
77 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::
79 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::target_indices_;
80
84
88
92
93 /** \brief Empty constructor.
94 *
95 * \note
96 * Sets the number of neighbors to be considered in the target point cloud (k_) to 10.
97 */
99 : source_normals_(), source_normals_transformed_(), target_normals_()
100 {
101 corr_name_ = "CorrespondenceEstimationBackProjection";
102 }
103
104 /** \brief Empty destructor */
106
107 /** \brief Set the normals computed on the source point cloud
108 * \param[in] normals the normals computed for the source cloud
109 */
110 inline void
112 {
113 source_normals_ = normals;
114 }
115
116 /** \brief Get the normals of the source point cloud
117 */
118 inline NormalsConstPtr
120 {
121 return (source_normals_);
122 }
123
124 /** \brief Set the normals computed on the target point cloud
125 * \param[in] normals the normals computed for the target cloud
126 */
127 inline void
129 {
130 target_normals_ = normals;
131 }
132
133 /** \brief Get the normals of the target point cloud
134 */
135 inline NormalsConstPtr
137 {
138 return (target_normals_);
139 }
140
141 /** \brief See if this rejector requires source normals */
142 bool
144 {
145 return (true);
146 }
147
148 /** \brief Blob method for setting the source normals */
149 void
151 {
152 const NormalsPtr cloud(new PointCloudNormals);
153 fromPCLPointCloud2(*cloud2, *cloud);
154 setSourceNormals(cloud);
155 }
156
157 /** \brief See if this rejector requires target normals*/
158 bool
160 {
161 return (true);
162 }
163
164 /** \brief Method for setting the target normals */
165 void
167 {
168 const NormalsPtr cloud(new PointCloudNormals);
169 fromPCLPointCloud2(*cloud2, *cloud);
170 setTargetNormals(cloud);
171 }
172
173 /** \brief Determine the correspondences between input and target cloud.
174 * \param[out] correspondences the found correspondences (index of query point, index
175 * of target point, distance) \param[in] max_distance maximum distance between the
176 * normal on the source point cloud and the corresponding point in the target point
177 * cloud
178 */
179 void
181 pcl::Correspondences& correspondences,
182 const double max_distance = std::numeric_limits<double>::max());
183
184 /** \brief Determine the reciprocal correspondences between input and target cloud.
185 * A correspondence is considered reciprocal if both Src_i has Tgt_i as a
186 * correspondence, and Tgt_i has Src_i as one.
187 *
188 * \param[out] correspondences the found correspondences (index of query and target
189 * point, distance) \param[in] max_distance maximum allowed distance between
190 * correspondences
191 */
192 virtual void
194 pcl::Correspondences& correspondences,
195 const double max_distance = std::numeric_limits<double>::max());
196
197 /** \brief Set the number of nearest neighbours to be considered in the target
198 * point cloud. By default, we use k = 10 nearest neighbors.
199 *
200 * \param[in] k the number of nearest neighbours to be considered
201 */
202 inline void
203 setKSearch(const unsigned int k)
204 {
205 k_ = k;
206 }
207
208 /** \brief Get the number of nearest neighbours considered in the target point
209 * cloud for computing correspondences. By default we use k = 10 nearest
210 * neighbors.
211 */
212 inline unsigned int
214 {
215 return (k_);
216 }
217
218 /** \brief Clone and cast to CorrespondenceEstimationBase */
220 clone() const
221 {
222 Ptr copy(new CorrespondenceEstimationBackProjection<PointSource,
223 PointTarget,
224 NormalT,
225 Scalar>(*this));
226 return (copy);
227 }
228
229protected:
230 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::corr_name_;
231 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::tree_;
232 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::
234 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::target_;
235
236 /** \brief Internal computation initialization. */
237 bool
238 initCompute();
239
240private:
241 /** \brief The normals computed at each point in the source cloud */
242 NormalsConstPtr source_normals_;
243
244 /** \brief The normals computed at each point in the source cloud */
245 NormalsPtr source_normals_transformed_;
246
247 /** \brief The normals computed at each point in the target cloud */
248 NormalsConstPtr target_normals_;
249
250 /** \brief The number of neighbours to be considered in the target point cloud */
251 unsigned int k_{10};
252};
253} // namespace registration
254} // namespace pcl
255
256#include <pcl/registration/impl/correspondence_estimation_backprojection.hpp>
PCL base class.
Definition pcl_base.h:70
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
bool deinitCompute()
This method should get called after finishing the actual computation.
Definition pcl_base.hpp:175
shared_ptr< PointCloud< PointSource > > Ptr
shared_ptr< const PointCloud< PointSource > > ConstPtr
CorrespondenceEstimationBackprojection computes correspondences as points in the target cloud which h...
void setSourceNormals(const NormalsConstPtr &normals)
Set the normals computed on the source point cloud.
shared_ptr< CorrespondenceEstimationBackProjection< PointSource, PointTarget, NormalT, Scalar > > Ptr
bool requiresTargetNormals() const
See if this rejector requires target normals.
virtual CorrespondenceEstimationBase< PointSource, PointTarget, Scalar >::Ptr clone() const
Clone and cast to CorrespondenceEstimationBase.
NormalsConstPtr getSourceNormals() const
Get the normals of the source point cloud.
shared_ptr< const CorrespondenceEstimationBackProjection< PointSource, PointTarget, NormalT, Scalar > > ConstPtr
void setTargetNormals(const pcl::PCLPointCloud2::ConstPtr cloud2)
Method for setting the target normals.
void determineCorrespondences(pcl::Correspondences &correspondences, const double max_distance=std::numeric_limits< double >::max())
Determine the correspondences between input and target cloud.
void setKSearch(const unsigned int k)
Set the number of nearest neighbours to be considered in the target point cloud.
void setSourceNormals(const pcl::PCLPointCloud2::ConstPtr cloud2)
Blob method for setting the source normals.
virtual void determineReciprocalCorrespondences(pcl::Correspondences &correspondences, const double max_distance=std::numeric_limits< double >::max())
Determine the reciprocal correspondences between input and target cloud.
unsigned int getKSearch() const
Get the number of nearest neighbours considered in the target point cloud for computing correspondenc...
NormalsConstPtr getTargetNormals() const
Get the normals of the target point cloud.
virtual ~CorrespondenceEstimationBackProjection()=default
Empty destructor.
bool requiresSourceNormals() const
See if this rejector requires source normals.
void setTargetNormals(const NormalsConstPtr &normals)
Set the normals computed on the target point cloud.
Abstract CorrespondenceEstimationBase class.
PointCloudTargetPtr input_transformed_
The transformed input source point cloud dataset.
PointCloudTargetConstPtr target_
The input point cloud dataset target.
PointRepresentationConstPtr point_representation_
The target point representation used (internal).
std::string corr_name_
The correspondence estimation method name.
const std::string & getClassName() const
Abstract class get name method.
KdTreePtr tree_
A pointer to the spatial search object used for the target dataset.
KdTreeReciprocalPtr tree_reciprocal_
A pointer to the spatial search object used for the source dataset.
bool initComputeReciprocal()
Internal computation initialization for reciprocal correspondences.
IndicesPtr target_indices_
The target point cloud dataset indices.
shared_ptr< CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > Ptr
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map, const std::uint8_t *msg_data)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
A point structure representing normal coordinates and the surface curvature estimate.
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr