Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2012-, Open Perception, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of the copyright holder(s) nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id$ 00037 * 00038 */ 00039 00040 #ifndef PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_H_ 00041 #define PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_H_ 00042 00043 #include <pcl/registration/correspondence_types.h> 00044 #include <pcl/registration/correspondence_estimation.h> 00045 00046 namespace pcl 00047 { 00048 namespace registration 00049 { 00050 /** \brief @b CorrespondenceEstimationBackprojection computes 00051 * correspondences as points in the target cloud which have minimum 00052 * \author Suat Gedikli 00053 * \ingroup registration 00054 */ 00055 template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar = float> 00056 class CorrespondenceEstimationBackProjection : public CorrespondenceEstimationBase <PointSource, PointTarget, Scalar> 00057 { 00058 public: 00059 typedef boost::shared_ptr<CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar> > Ptr; 00060 typedef boost::shared_ptr<const CorrespondenceEstimationBackProjection<PointSource, PointTarget, NormalT, Scalar> > ConstPtr; 00061 00062 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initCompute; 00063 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initComputeReciprocal; 00064 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::input_transformed_; 00065 using PCLBase<PointSource>::deinitCompute; 00066 using PCLBase<PointSource>::input_; 00067 using PCLBase<PointSource>::indices_; 00068 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::getClassName; 00069 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::point_representation_; 00070 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::target_indices_; 00071 00072 typedef typename pcl::search::KdTree<PointTarget> KdTree; 00073 typedef typename pcl::search::KdTree<PointTarget>::Ptr KdTreePtr; 00074 00075 typedef pcl::PointCloud<PointSource> PointCloudSource; 00076 typedef typename PointCloudSource::Ptr PointCloudSourcePtr; 00077 typedef typename PointCloudSource::ConstPtr PointCloudSourceConstPtr; 00078 00079 typedef pcl::PointCloud<PointTarget> PointCloudTarget; 00080 typedef typename PointCloudTarget::Ptr PointCloudTargetPtr; 00081 typedef typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr; 00082 00083 typedef pcl::PointCloud<NormalT> PointCloudNormals; 00084 typedef typename PointCloudNormals::Ptr NormalsPtr; 00085 typedef typename PointCloudNormals::ConstPtr NormalsConstPtr; 00086 00087 /** \brief Empty constructor. 00088 * 00089 * \note 00090 * Sets the number of neighbors to be considered in the target point cloud (k_) to 10. 00091 */ 00092 CorrespondenceEstimationBackProjection () 00093 : source_normals_ () 00094 , source_normals_transformed_ () 00095 , target_normals_ () 00096 , k_ (10) 00097 { 00098 corr_name_ = "CorrespondenceEstimationBackProjection"; 00099 } 00100 00101 /** \brief Empty destructor */ 00102 virtual ~CorrespondenceEstimationBackProjection () {} 00103 00104 /** \brief Set the normals computed on the source point cloud 00105 * \param[in] normals the normals computed for the source cloud 00106 */ 00107 inline void 00108 setSourceNormals (const NormalsConstPtr &normals) { source_normals_ = normals; } 00109 00110 /** \brief Get the normals of the source point cloud 00111 */ 00112 inline NormalsConstPtr 00113 getSourceNormals () const { return (source_normals_); } 00114 00115 /** \brief Set the normals computed on the target point cloud 00116 * \param[in] normals the normals computed for the target cloud 00117 */ 00118 inline void 00119 setTargetNormals (const NormalsConstPtr &normals) { target_normals_ = normals; } 00120 00121 /** \brief Get the normals of the target point cloud 00122 */ 00123 inline NormalsConstPtr 00124 getTargetNormals () const { return (target_normals_); } 00125 00126 /** \brief Determine the correspondences between input and target cloud. 00127 * \param[out] correspondences the found correspondences (index of query point, index of target point, distance) 00128 * \param[in] max_distance maximum distance between the normal on the source point cloud and the corresponding point in the target 00129 * point cloud 00130 */ 00131 void 00132 determineCorrespondences (pcl::Correspondences &correspondences, 00133 double max_distance = std::numeric_limits<double>::max ()); 00134 00135 /** \brief Determine the reciprocal correspondences between input and target cloud. 00136 * A correspondence is considered reciprocal if both Src_i has Tgt_i as a 00137 * correspondence, and Tgt_i has Src_i as one. 00138 * 00139 * \param[out] correspondences the found correspondences (index of query and target point, distance) 00140 * \param[in] max_distance maximum allowed distance between correspondences 00141 */ 00142 virtual void 00143 determineReciprocalCorrespondences (pcl::Correspondences &correspondences, 00144 double max_distance = std::numeric_limits<double>::max ()); 00145 00146 /** \brief Set the number of nearest neighbours to be considered in the target 00147 * point cloud. By default, we use k = 10 nearest neighbors. 00148 * 00149 * \param[in] k the number of nearest neighbours to be considered 00150 */ 00151 inline void 00152 setKSearch (unsigned int k) { k_ = k; } 00153 00154 /** \brief Get the number of nearest neighbours considered in the target point 00155 * cloud for computing correspondences. By default we use k = 10 nearest 00156 * neighbors. 00157 */ 00158 inline void 00159 getKSearch () const { return (k_); } 00160 00161 protected: 00162 00163 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::corr_name_; 00164 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::tree_; 00165 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::tree_reciprocal_; 00166 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::target_; 00167 00168 /** \brief Internal computation initalization. */ 00169 bool 00170 initCompute (); 00171 00172 private: 00173 00174 /** \brief The normals computed at each point in the source cloud */ 00175 NormalsConstPtr source_normals_; 00176 00177 /** \brief The normals computed at each point in the source cloud */ 00178 NormalsPtr source_normals_transformed_; 00179 00180 /** \brief The normals computed at each point in the target cloud */ 00181 NormalsConstPtr target_normals_; 00182 00183 /** \brief The number of neighbours to be considered in the target point cloud */ 00184 unsigned int k_; 00185 }; 00186 } 00187 } 00188 00189 #include <pcl/registration/impl/correspondence_estimation_backprojection.hpp> 00190 00191 #endif /* PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_BACK_PROJECTION_H_ */