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