00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_H_
00042 #define PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_H_
00043
00044 #include <string>
00045
00046 #include <pcl/pcl_base.h>
00047 #include <pcl/common/transforms.h>
00048 #include <pcl/search/kdtree.h>
00049 #include <pcl/pcl_macros.h>
00050
00051 #include <pcl/registration/correspondence_types.h>
00052
00053 namespace pcl
00054 {
00055 namespace registration
00056 {
00062 template <typename PointSource, typename PointTarget, typename Scalar = float>
00063 class CorrespondenceEstimationBase: public PCLBase<PointSource>
00064 {
00065 public:
00066 typedef boost::shared_ptr<CorrespondenceEstimationBase<PointSource, PointTarget, Scalar> > Ptr;
00067 typedef boost::shared_ptr<const CorrespondenceEstimationBase<PointSource, PointTarget, Scalar> > ConstPtr;
00068
00069
00070 using PCLBase<PointSource>::deinitCompute;
00071 using PCLBase<PointSource>::input_;
00072 using PCLBase<PointSource>::indices_;
00073 using PCLBase<PointSource>::setIndices;
00074
00075 typedef pcl::search::KdTree<PointTarget> KdTree;
00076 typedef typename KdTree::Ptr KdTreePtr;
00077
00078 typedef pcl::search::KdTree<PointSource> KdTreeReciprocal;
00079 typedef typename KdTree::Ptr KdTreeReciprocalPtr;
00080
00081 typedef pcl::PointCloud<PointSource> PointCloudSource;
00082 typedef typename PointCloudSource::Ptr PointCloudSourcePtr;
00083 typedef typename PointCloudSource::ConstPtr PointCloudSourceConstPtr;
00084
00085 typedef pcl::PointCloud<PointTarget> PointCloudTarget;
00086 typedef typename PointCloudTarget::Ptr PointCloudTargetPtr;
00087 typedef typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr;
00088
00089 typedef typename KdTree::PointRepresentationConstPtr PointRepresentationConstPtr;
00090
00092 CorrespondenceEstimationBase ()
00093 : corr_name_ ("CorrespondenceEstimationBase")
00094 , tree_ (new pcl::search::KdTree<PointTarget>)
00095 , tree_reciprocal_ (new pcl::search::KdTree<PointSource>)
00096 , target_ ()
00097 , target_indices_ ()
00098 , point_representation_ ()
00099 , input_transformed_ ()
00100 , input_fields_ ()
00101 , target_cloud_updated_ (true)
00102 , source_cloud_updated_ (true)
00103 , force_no_recompute_ (false)
00104 , force_no_recompute_reciprocal_ (false)
00105 {
00106 }
00107
00109 virtual ~CorrespondenceEstimationBase () {}
00110
00116 PCL_DEPRECATED (void setInputCloud (const PointCloudSourceConstPtr &cloud), "[pcl::registration::CorrespondenceEstimationBase::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.");
00117
00119 PCL_DEPRECATED (PointCloudSourceConstPtr const getInputCloud (),
00120 "[pcl::registration::CorrespondenceEstimationBase::getInputCloud] getInputCloud is deprecated. Please use getInputSource instead.");
00121
00127 inline void
00128 setInputSource (const PointCloudSourceConstPtr &cloud)
00129 {
00130 source_cloud_updated_ = true;
00131 PCLBase<PointSource>::setInputCloud (cloud);
00132 pcl::getFields (*cloud, input_fields_);
00133 }
00134
00136 inline PointCloudSourceConstPtr const
00137 getInputSource ()
00138 {
00139 return (input_ );
00140 }
00141
00146 inline void
00147 setInputTarget (const PointCloudTargetConstPtr &cloud);
00148
00150 inline PointCloudTargetConstPtr const
00151 getInputTarget () { return (target_ ); }
00152
00157 inline void
00158 setIndicesSource (const IndicesPtr &indices)
00159 {
00160 setIndices (indices);
00161 }
00162
00164 inline IndicesPtr const
00165 getIndicesSource () { return (indices_); }
00166
00170 inline void
00171 setIndicesTarget (const IndicesPtr &indices)
00172 {
00173 target_cloud_updated_ = true;
00174 target_indices_ = indices;
00175 }
00176
00178 inline IndicesPtr const
00179 getIndicesTarget () { return (target_indices_); }
00180
00188 inline void
00189 setSearchMethodTarget (const KdTreePtr &tree,
00190 bool force_no_recompute = false)
00191 {
00192 tree_ = tree;
00193 if (force_no_recompute)
00194 {
00195 force_no_recompute_ = true;
00196 }
00197
00198 target_cloud_updated_ = true;
00199 }
00200
00203 inline KdTreePtr
00204 getSearchMethodTarget () const
00205 {
00206 return (tree_);
00207 }
00208
00216 inline void
00217 setSearchMethodSource (const KdTreeReciprocalPtr &tree,
00218 bool force_no_recompute = false)
00219 {
00220 tree_reciprocal_ = tree;
00221 if ( force_no_recompute )
00222 {
00223 force_no_recompute_reciprocal_ = true;
00224 }
00225
00226 source_cloud_updated_ = true;
00227 }
00228
00231 inline KdTreeReciprocalPtr
00232 getSearchMethodSource () const
00233 {
00234 return (tree_reciprocal_);
00235 }
00236
00241 virtual void
00242 determineCorrespondences (pcl::Correspondences &correspondences,
00243 double max_distance = std::numeric_limits<double>::max ()) = 0;
00244
00252 virtual void
00253 determineReciprocalCorrespondences (pcl::Correspondences &correspondences,
00254 double max_distance = std::numeric_limits<double>::max ()) = 0;
00255
00262 inline void
00263 setPointRepresentation (const PointRepresentationConstPtr &point_representation)
00264 {
00265 point_representation_ = point_representation;
00266 }
00267
00268 protected:
00270 std::string corr_name_;
00271
00273 KdTreePtr tree_;
00274
00276 KdTreeReciprocalPtr tree_reciprocal_;
00277
00278
00279
00281 PointCloudTargetConstPtr target_;
00282
00284 IndicesPtr target_indices_;
00285
00287 PointRepresentationConstPtr point_representation_;
00288
00290 PointCloudTargetPtr input_transformed_;
00291
00293 std::vector<pcl::PCLPointField> input_fields_;
00294
00296 inline const std::string&
00297 getClassName () const { return (corr_name_); }
00298
00300 bool
00301 initCompute ();
00302
00304 bool
00305 initComputeReciprocal ();
00306
00310 bool target_cloud_updated_;
00314 bool source_cloud_updated_;
00317 bool force_no_recompute_;
00318
00321 bool force_no_recompute_reciprocal_;
00322
00323 };
00324
00346 template <typename PointSource, typename PointTarget, typename Scalar = float>
00347 class CorrespondenceEstimation : public CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>
00348 {
00349 public:
00350 typedef boost::shared_ptr<CorrespondenceEstimation<PointSource, PointTarget, Scalar> > Ptr;
00351 typedef boost::shared_ptr<const CorrespondenceEstimation<PointSource, PointTarget, Scalar> > ConstPtr;
00352
00353 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::point_representation_;
00354 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::input_transformed_;
00355 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::tree_;
00356 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::tree_reciprocal_;
00357 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::target_;
00358 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::corr_name_;
00359 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::target_indices_;
00360 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::getClassName;
00361 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initCompute;
00362 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initComputeReciprocal;
00363 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::input_;
00364 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::indices_;
00365 using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::input_fields_;
00366 using PCLBase<PointSource>::deinitCompute;
00367
00368 typedef pcl::search::KdTree<PointTarget> KdTree;
00369 typedef typename pcl::search::KdTree<PointTarget>::Ptr KdTreePtr;
00370
00371 typedef pcl::PointCloud<PointSource> PointCloudSource;
00372 typedef typename PointCloudSource::Ptr PointCloudSourcePtr;
00373 typedef typename PointCloudSource::ConstPtr PointCloudSourceConstPtr;
00374
00375 typedef pcl::PointCloud<PointTarget> PointCloudTarget;
00376 typedef typename PointCloudTarget::Ptr PointCloudTargetPtr;
00377 typedef typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr;
00378
00379 typedef typename KdTree::PointRepresentationConstPtr PointRepresentationConstPtr;
00380
00382 CorrespondenceEstimation ()
00383 {
00384 corr_name_ = "CorrespondenceEstimation";
00385 }
00386
00388 virtual ~CorrespondenceEstimation () {}
00389
00394 virtual void
00395 determineCorrespondences (pcl::Correspondences &correspondences,
00396 double max_distance = std::numeric_limits<double>::max ());
00397
00405 virtual void
00406 determineReciprocalCorrespondences (pcl::Correspondences &correspondences,
00407 double max_distance = std::numeric_limits<double>::max ());
00408 };
00409 }
00410 }
00411
00412 #include <pcl/registration/impl/correspondence_estimation.hpp>
00413
00414 #endif