1 /* 2 * Software License Agreement (BSD License) 3 * 4 * Point Cloud Library (PCL) - www.pointclouds.org 5 * Copyright (c) 2015, Michael 'v4hn' Goerner 6 * Copyright (c) 2015-, Open Perception, Inc. 7 * 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 14 * * Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * * Redistributions in binary form must reproduce the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer in the documentation and/or other materials provided 19 * with the distribution. 20 * * Neither the name of the copyright holder(s) nor the names of its 21 * contributors may be used to endorse or promote products derived 22 * from this software without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38 #pragma once 39 40 #include <pcl/registration/registration.h> 41 #include <pcl/point_cloud.h> 42 43 namespace pcl { 44 namespace registration { 45 46 /** \brief Meta @ref Registration class 47 * \note This method accumulates all registered points and becomes more costly with each 48 * registered point cloud. 49 * 50 * This class provides a way to register a stream of clouds where each cloud 51 * will be aligned to the conglomerate of all previous clouds. 52 * 53 * \code 54 * IterativeClosestPoint<PointXYZ,PointXYZ>::Ptr icp 55 * (new IterativeClosestPoint<PointXYZ,PointXYZ>); 56 * icp->setMaxCorrespondenceDistance (0.05); 57 * icp->setMaximumIterations (50); 58 * 59 * MetaRegistration<PointXYZ> mreg; 60 * mreg.setRegistration (icp); 61 * 62 * while (true) 63 * { 64 * PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ>); 65 * read_cloud (*cloud); 66 * mreg.registerCloud (cloud); 67 * 68 * PointCloud<PointXYZ>::Ptr tmp (new PointCloud<PointXYZ>); 69 * transformPointCloud (*cloud, *tmp, mreg.getAbsoluteTransform ()); 70 * write_cloud (*tmp); 71 * } 72 * \endcode 73 * 74 * \author Michael 'v4hn' Goerner 75 * \ingroup registration 76 */ 77 template <typename PointT, typename Scalar = float> 78 class MetaRegistration { 79 public: 80 using PointCloudPtr = typename pcl::PointCloud<PointT>::Ptr; 81 using PointCloudConstPtr = typename pcl::PointCloud<PointT>::ConstPtr; 82 83 using RegistrationPtr = typename pcl::Registration<PointT, PointT, Scalar>::Ptr; 84 using Matrix4 = typename pcl::Registration<PointT, PointT, Scalar>::Matrix4; 85 86 MetaRegistration(); 87 88 /** \brief Empty destructor */ ~MetaRegistration()89 virtual ~MetaRegistration(){}; 90 91 /** \brief Register new point cloud 92 * \note You have to set a valid registration object with \ref setRegistration before 93 * using this \param[in] cloud point cloud to register \param[in] delta_estimate 94 * estimated transform between last registered cloud and this one \return true if 95 * registration converged 96 */ 97 bool 98 registerCloud(const PointCloudConstPtr& cloud, 99 const Matrix4& delta_estimate = Matrix4::Identity()); 100 101 /** \brief Get estimated transform of the last registered cloud */ 102 inline Matrix4 103 getAbsoluteTransform() const; 104 105 /** \brief Reset MetaRegistration without resetting registration_ */ 106 inline void 107 reset(); 108 109 /** \brief Set registration instance used to align clouds */ 110 inline void setRegistration(RegistrationPtr); 111 112 /** \brief get accumulated meta point cloud */ 113 inline PointCloudConstPtr 114 getMetaCloud() const; 115 116 protected: 117 /** \brief registered accumulated point cloud */ 118 PointCloudPtr full_cloud_; 119 120 /** \brief registration instance to align clouds */ 121 RegistrationPtr registration_; 122 123 /** \brief estimated transform */ 124 Matrix4 abs_transform_; 125 }; 126 127 } // namespace registration 128 } // namespace pcl 129 130 #include <pcl/registration/impl/meta_registration.hpp> 131