Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of the copyright holder(s) nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * $Id$ 00035 * 00036 */ 00037 00038 #ifndef PCL_SEGMENT_DIFFERENCES_H_ 00039 #define PCL_SEGMENT_DIFFERENCES_H_ 00040 00041 #include <pcl/pcl_base.h> 00042 #include <pcl/search/pcl_search.h> 00043 00044 namespace pcl 00045 { 00046 //////////////////////////////////////////////////////////////////////////////////////////// 00047 /** \brief Obtain the difference between two aligned point clouds as another point cloud, given a distance threshold. 00048 * \param src the input point cloud source 00049 * \param tgt the input point cloud target we need to obtain the difference against 00050 * \param threshold the distance threshold (tolerance) for point correspondences. (e.g., check if f a point p1 from 00051 * src has a correspondence > threshold than a point p2 from tgt) 00052 * \param tree the spatial locator (e.g., kd-tree) used for nearest neighbors searching built over \a tgt 00053 * \param output the resultant output point cloud difference 00054 * \ingroup segmentation 00055 */ 00056 template <typename PointT> 00057 void getPointCloudDifference ( 00058 const pcl::PointCloud<PointT> &src, const pcl::PointCloud<PointT> &tgt, 00059 double threshold, const boost::shared_ptr<pcl::search::Search<PointT> > &tree, 00060 pcl::PointCloud<PointT> &output); 00061 00062 //////////////////////////////////////////////////////////////////////////////////////////// 00063 //////////////////////////////////////////////////////////////////////////////////////////// 00064 //////////////////////////////////////////////////////////////////////////////////////////// 00065 /** \brief @b SegmentDifferences obtains the difference between two spatially 00066 * aligned point clouds and returns the difference between them for a maximum 00067 * given distance threshold. 00068 * \author Radu Bogdan Rusu 00069 * \ingroup segmentation 00070 */ 00071 template <typename PointT> 00072 class SegmentDifferences: public PCLBase<PointT> 00073 { 00074 typedef PCLBase<PointT> BasePCLBase; 00075 00076 public: 00077 typedef pcl::PointCloud<PointT> PointCloud; 00078 typedef typename PointCloud::Ptr PointCloudPtr; 00079 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00080 00081 typedef typename pcl::search::Search<PointT> KdTree; 00082 typedef typename pcl::search::Search<PointT>::Ptr KdTreePtr; 00083 00084 typedef PointIndices::Ptr PointIndicesPtr; 00085 typedef PointIndices::ConstPtr PointIndicesConstPtr; 00086 00087 /** \brief Empty constructor. */ 00088 SegmentDifferences () : 00089 tree_ (), target_ (), distance_threshold_ (0) 00090 {}; 00091 00092 /** \brief Provide a pointer to the target dataset against which we 00093 * compare the input cloud given in setInputCloud 00094 * 00095 * \param cloud the target PointCloud dataset 00096 */ 00097 inline void 00098 setTargetCloud (const PointCloudConstPtr &cloud) { target_ = cloud; } 00099 00100 /** \brief Get a pointer to the input target point cloud dataset. */ 00101 inline PointCloudConstPtr const 00102 getTargetCloud () { return (target_); } 00103 00104 /** \brief Provide a pointer to the search object. 00105 * \param tree a pointer to the spatial search object. 00106 */ 00107 inline void 00108 setSearchMethod (const KdTreePtr &tree) { tree_ = tree; } 00109 00110 /** \brief Get a pointer to the search method used. */ 00111 inline KdTreePtr 00112 getSearchMethod () { return (tree_); } 00113 00114 /** \brief Set the maximum distance tolerance (squared) between corresponding 00115 * points in the two input datasets. 00116 * 00117 * \param sqr_threshold the squared distance tolerance as a measure in L2 Euclidean space 00118 */ 00119 inline void 00120 setDistanceThreshold (double sqr_threshold) { distance_threshold_ = sqr_threshold; } 00121 00122 /** \brief Get the squared distance tolerance between corresponding points as a 00123 * measure in the L2 Euclidean space. 00124 */ 00125 inline double 00126 getDistanceThreshold () { return (distance_threshold_); } 00127 00128 /** \brief Segment differences between two input point clouds. 00129 * \param output the resultant difference between the two point clouds as a PointCloud 00130 */ 00131 void 00132 segment (PointCloud &output); 00133 00134 protected: 00135 // Members derived from the base class 00136 using BasePCLBase::input_; 00137 using BasePCLBase::indices_; 00138 using BasePCLBase::initCompute; 00139 using BasePCLBase::deinitCompute; 00140 00141 /** \brief A pointer to the spatial search object. */ 00142 KdTreePtr tree_; 00143 00144 /** \brief The input target point cloud dataset. */ 00145 PointCloudConstPtr target_; 00146 00147 /** \brief The distance tolerance (squared) as a measure in the L2 00148 * Euclidean space between corresponding points. 00149 */ 00150 double distance_threshold_; 00151 00152 /** \brief Class getName method. */ 00153 virtual std::string 00154 getClassName () const { return ("SegmentDifferences"); } 00155 }; 00156 } 00157 00158 #ifdef PCL_NO_PRECOMPILE 00159 #include <pcl/segmentation/impl/segment_differences.hpp> 00160 #endif 00161 00162 #endif //#ifndef PCL_SEGMENT_DIFFERENCES_H_