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 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_POINT_TO_PLANE_WEIGHTED_H_
00041 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_POINT_TO_PLANE_WEIGHTED_H_
00042
00043 #include <pcl/registration/transformation_estimation_point_to_plane.h>
00044 #include <pcl/registration/warp_point_rigid.h>
00045 #include <pcl/registration/distances.h>
00046
00047 namespace pcl
00048 {
00049 namespace registration
00050 {
00058 template <typename PointSource, typename PointTarget, typename MatScalar = float>
00059 class TransformationEstimationPointToPlaneWeighted : public TransformationEstimationPointToPlane<PointSource, PointTarget, MatScalar>
00060 {
00061 typedef pcl::PointCloud<PointSource> PointCloudSource;
00062 typedef typename PointCloudSource::Ptr PointCloudSourcePtr;
00063 typedef typename PointCloudSource::ConstPtr PointCloudSourceConstPtr;
00064
00065 typedef pcl::PointCloud<PointTarget> PointCloudTarget;
00066
00067 typedef PointIndices::Ptr PointIndicesPtr;
00068 typedef PointIndices::ConstPtr PointIndicesConstPtr;
00069
00070 public:
00071 typedef boost::shared_ptr<TransformationEstimationPointToPlaneWeighted<PointSource, PointTarget, MatScalar> > Ptr;
00072 typedef boost::shared_ptr<const TransformationEstimationPointToPlaneWeighted<PointSource, PointTarget, MatScalar> > ConstPtr;
00073
00074 typedef Eigen::Matrix<MatScalar, Eigen::Dynamic, 1> VectorX;
00075 typedef Eigen::Matrix<MatScalar, 4, 1> Vector4;
00076 typedef typename TransformationEstimation<PointSource, PointTarget, MatScalar>::Matrix4 Matrix4;
00077
00079 TransformationEstimationPointToPlaneWeighted ();
00080
00084 TransformationEstimationPointToPlaneWeighted (const TransformationEstimationPointToPlaneWeighted &src) :
00085 tmp_src_ (src.tmp_src_),
00086 tmp_tgt_ (src.tmp_tgt_),
00087 tmp_idx_src_ (src.tmp_idx_src_),
00088 tmp_idx_tgt_ (src.tmp_idx_tgt_),
00089 warp_point_ (src.warp_point_),
00090 correspondence_weights_ (src.correspondence_weights_),
00091 use_correspondence_weights_ (src.use_correspondence_weights_)
00092 {};
00093
00097 TransformationEstimationPointToPlaneWeighted&
00098 operator = (const TransformationEstimationPointToPlaneWeighted &src)
00099 {
00100 tmp_src_ = src.tmp_src_;
00101 tmp_tgt_ = src.tmp_tgt_;
00102 tmp_idx_src_ = src.tmp_idx_src_;
00103 tmp_idx_tgt_ = src.tmp_idx_tgt_;
00104 warp_point_ = src.warp_point_;
00105 correspondence_weights_ = src.correspondence_weights_;
00106 use_correspondence_weights_ = src.use_correspondence_weights_;
00107 }
00108
00110 virtual ~TransformationEstimationPointToPlaneWeighted () {};
00111
00118 inline void
00119 estimateRigidTransformation (
00120 const pcl::PointCloud<PointSource> &cloud_src,
00121 const pcl::PointCloud<PointTarget> &cloud_tgt,
00122 Matrix4 &transformation_matrix) const;
00123
00131 inline void
00132 estimateRigidTransformation (
00133 const pcl::PointCloud<PointSource> &cloud_src,
00134 const std::vector<int> &indices_src,
00135 const pcl::PointCloud<PointTarget> &cloud_tgt,
00136 Matrix4 &transformation_matrix) const;
00137
00147 void
00148 estimateRigidTransformation (
00149 const pcl::PointCloud<PointSource> &cloud_src,
00150 const std::vector<int> &indices_src,
00151 const pcl::PointCloud<PointTarget> &cloud_tgt,
00152 const std::vector<int> &indices_tgt,
00153 Matrix4 &transformation_matrix) const;
00154
00162 void
00163 estimateRigidTransformation (
00164 const pcl::PointCloud<PointSource> &cloud_src,
00165 const pcl::PointCloud<PointTarget> &cloud_tgt,
00166 const pcl::Correspondences &correspondences,
00167 Matrix4 &transformation_matrix) const;
00168
00169
00170 inline void
00171 setWeights (const std::vector<double> &weights)
00172 { correspondence_weights_ = weights; }
00173
00175 inline void
00176 setUseCorrespondenceWeights (bool use_correspondence_weights)
00177 { use_correspondence_weights_ = use_correspondence_weights; }
00178
00182 void
00183 setWarpFunction (const boost::shared_ptr<WarpPointRigid<PointSource, PointTarget, MatScalar> > &warp_fcn)
00184 { warp_point_ = warp_fcn; }
00185
00186 protected:
00187 bool use_correspondence_weights_;
00188 mutable std::vector<double> correspondence_weights_;
00189
00191 mutable const PointCloudSource *tmp_src_;
00192
00194 mutable const PointCloudTarget *tmp_tgt_;
00195
00197 mutable const std::vector<int> *tmp_idx_src_;
00198
00200 mutable const std::vector<int> *tmp_idx_tgt_;
00201
00203 boost::shared_ptr<pcl::registration::WarpPointRigid<PointSource, PointTarget, MatScalar> > warp_point_;
00204
00209 template<typename _Scalar, int NX=Eigen::Dynamic, int NY=Eigen::Dynamic>
00210 struct Functor
00211 {
00212 typedef _Scalar Scalar;
00213 enum
00214 {
00215 InputsAtCompileTime = NX,
00216 ValuesAtCompileTime = NY
00217 };
00218 typedef Eigen::Matrix<_Scalar,InputsAtCompileTime,1> InputType;
00219 typedef Eigen::Matrix<_Scalar,ValuesAtCompileTime,1> ValueType;
00220 typedef Eigen::Matrix<_Scalar,ValuesAtCompileTime,InputsAtCompileTime> JacobianType;
00221
00223 Functor () : m_data_points_ (ValuesAtCompileTime) {}
00224
00228 Functor (int m_data_points) : m_data_points_ (m_data_points) {}
00229
00231 virtual ~Functor () {}
00232
00234 int
00235 values () const { return (m_data_points_); }
00236
00237 protected:
00238 int m_data_points_;
00239 };
00240
00241 struct OptimizationFunctor : public Functor<MatScalar>
00242 {
00243 using Functor<MatScalar>::values;
00244
00249 OptimizationFunctor (int m_data_points,
00250 const TransformationEstimationPointToPlaneWeighted *estimator)
00251 : Functor<MatScalar> (m_data_points), estimator_ (estimator)
00252 {}
00253
00257 inline OptimizationFunctor (const OptimizationFunctor &src) :
00258 Functor<MatScalar> (src.m_data_points_), estimator_ ()
00259 {
00260 *this = src;
00261 }
00262
00266 inline OptimizationFunctor&
00267 operator = (const OptimizationFunctor &src)
00268 {
00269 Functor<MatScalar>::operator=(src);
00270 estimator_ = src.estimator_;
00271 return (*this);
00272 }
00273
00275 virtual ~OptimizationFunctor () {}
00276
00281 int
00282 operator () (const VectorX &x, VectorX &fvec) const;
00283
00284 const TransformationEstimationPointToPlaneWeighted<PointSource, PointTarget, MatScalar> *estimator_;
00285 };
00286
00287 struct OptimizationFunctorWithIndices : public Functor<MatScalar>
00288 {
00289 using Functor<MatScalar>::values;
00290
00295 OptimizationFunctorWithIndices (int m_data_points,
00296 const TransformationEstimationPointToPlaneWeighted *estimator)
00297 : Functor<MatScalar> (m_data_points), estimator_ (estimator)
00298 {}
00299
00303 inline OptimizationFunctorWithIndices (const OptimizationFunctorWithIndices &src)
00304 : Functor<MatScalar> (src.m_data_points_), estimator_ ()
00305 {
00306 *this = src;
00307 }
00308
00312 inline OptimizationFunctorWithIndices&
00313 operator = (const OptimizationFunctorWithIndices &src)
00314 {
00315 Functor<MatScalar>::operator=(src);
00316 estimator_ = src.estimator_;
00317 return (*this);
00318 }
00319
00321 virtual ~OptimizationFunctorWithIndices () {}
00322
00327 int
00328 operator () (const VectorX &x, VectorX &fvec) const;
00329
00330 const TransformationEstimationPointToPlaneWeighted<PointSource, PointTarget, MatScalar> *estimator_;
00331 };
00332 public:
00333 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00334 };
00335 }
00336 }
00337
00338 #include <pcl/registration/impl/transformation_estimation_point_to_plane_weighted.hpp>
00339
00340 #endif
00341