Point Cloud Library (PCL)
1.3.1
|
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 Willow Garage, Inc. 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: statistical_outlier_removal.h 3028 2011-11-01 04:12:17Z rusu $ 00035 * 00036 */ 00037 00038 #ifndef PCL_FILTERS_STATISTICALOUTLIERREMOVAL_H_ 00039 #define PCL_FILTERS_STATISTICALOUTLIERREMOVAL_H_ 00040 00041 #include "pcl/point_types.h" 00042 #include "pcl/filters/filter.h" 00043 #include "pcl/search/pcl_search.h" 00044 #include "pcl/common/common.h" 00045 00046 namespace pcl 00047 { 00060 template<typename PointT> 00061 class StatisticalOutlierRemoval : public Filter<PointT> 00062 { 00063 using Filter<PointT>::input_; 00064 using Filter<PointT>::indices_; 00065 using Filter<PointT>::filter_name_; 00066 using Filter<PointT>::getClassName; 00067 00068 using Filter<PointT>::removed_indices_; 00069 using Filter<PointT>::extract_removed_indices_; 00070 00071 typedef typename pcl::search::Search<PointT> KdTree; 00072 typedef typename pcl::search::Search<PointT>::Ptr KdTreePtr; 00073 00074 typedef typename Filter<PointT>::PointCloud PointCloud; 00075 typedef typename PointCloud::Ptr PointCloudPtr; 00076 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00077 00078 public: 00080 StatisticalOutlierRemoval (bool extract_removed_indices = false) : 00081 Filter<PointT>::Filter (extract_removed_indices), mean_k_ (2), std_mul_ (0.0), tree_ (), negative_ (false) 00082 { 00083 filter_name_ = "StatisticalOutlierRemoval"; 00084 } 00085 00089 inline void 00090 setMeanK (int nr_k) 00091 { 00092 mean_k_ = nr_k; 00093 } 00094 00096 inline int 00097 getMeanK () 00098 { 00099 return (mean_k_); 00100 } 00101 00108 inline void 00109 setStddevMulThresh (double std_mul) 00110 { 00111 std_mul_ = std_mul; 00112 } 00113 00115 inline double 00116 getStddevMulThresh () 00117 { 00118 return (std_mul_); 00119 } 00120 00124 inline void 00125 setNegative (bool negative) 00126 { 00127 negative_ = negative; 00128 } 00129 00133 inline bool 00134 getNegative () 00135 { 00136 return (negative_); 00137 } 00138 00139 protected: 00141 int mean_k_; 00142 00145 double std_mul_; 00146 00148 KdTreePtr tree_; 00149 00151 bool negative_; 00152 00156 void 00157 applyFilter (PointCloud &output); 00158 }; 00159 00172 template<> 00173 class PCL_EXPORTS StatisticalOutlierRemoval<sensor_msgs::PointCloud2> : public Filter<sensor_msgs::PointCloud2> 00174 { 00175 using Filter<sensor_msgs::PointCloud2>::filter_name_; 00176 using Filter<sensor_msgs::PointCloud2>::getClassName; 00177 00178 using Filter<sensor_msgs::PointCloud2>::removed_indices_; 00179 using Filter<sensor_msgs::PointCloud2>::extract_removed_indices_; 00180 00181 typedef pcl::search::Search<pcl::PointXYZ> KdTree; 00182 typedef pcl::search::Search<pcl::PointXYZ>::Ptr KdTreePtr; 00183 00184 typedef sensor_msgs::PointCloud2 PointCloud2; 00185 typedef PointCloud2::Ptr PointCloud2Ptr; 00186 typedef PointCloud2::ConstPtr PointCloud2ConstPtr; 00187 00188 public: 00190 StatisticalOutlierRemoval (bool extract_removed_indices = false) : 00191 Filter<sensor_msgs::PointCloud2>::Filter (extract_removed_indices), mean_k_ (2), 00192 std_mul_ (0.0), tree_ (), negative_ (false) 00193 { 00194 filter_name_ = "StatisticalOutlierRemoval"; 00195 } 00196 00200 inline void 00201 setMeanK (int nr_k) 00202 { 00203 mean_k_ = nr_k; 00204 } 00205 00207 inline int 00208 getMeanK () 00209 { 00210 return (mean_k_); 00211 } 00212 00219 inline void 00220 setStddevMulThresh (double std_mul) 00221 { 00222 std_mul_ = std_mul; 00223 } 00224 00226 inline double 00227 getStddevMulThresh () 00228 { 00229 return (std_mul_); 00230 } 00231 00235 inline void 00236 setNegative (bool negative) 00237 { 00238 negative_ = negative; 00239 } 00240 00244 inline bool 00245 getNegative () 00246 { 00247 return (negative_); 00248 } 00249 00250 protected: 00252 int mean_k_; 00253 00257 double std_mul_; 00258 00260 KdTreePtr tree_; 00261 00263 bool negative_; 00264 00265 void 00266 applyFilter (PointCloud2 &output); 00267 }; 00268 } 00269 00270 #endif //#ifndef PCL_FILTERS_STATISTICALOUTLIERREMOVAL_H_