|
Point Cloud Library (PCL)
1.5.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 4702 2012-02-23 09:39:33Z gedikli $ 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 { 00058 template<typename PointT> 00059 class StatisticalOutlierRemoval : public Filter<PointT> 00060 { 00061 using Filter<PointT>::input_; 00062 using Filter<PointT>::indices_; 00063 using Filter<PointT>::filter_name_; 00064 using Filter<PointT>::getClassName; 00065 00066 using Filter<PointT>::removed_indices_; 00067 using Filter<PointT>::extract_removed_indices_; 00068 00069 typedef typename pcl::search::Search<PointT> KdTree; 00070 typedef typename pcl::search::Search<PointT>::Ptr KdTreePtr; 00071 00072 typedef typename Filter<PointT>::PointCloud PointCloud; 00073 typedef typename PointCloud::Ptr PointCloudPtr; 00074 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00075 00076 public: 00078 StatisticalOutlierRemoval (bool extract_removed_indices = false) : 00079 Filter<PointT>::Filter (extract_removed_indices), mean_k_ (2), std_mul_ (0.0), tree_ (), negative_ (false) 00080 { 00081 filter_name_ = "StatisticalOutlierRemoval"; 00082 } 00083 00087 inline void 00088 setMeanK (int nr_k) 00089 { 00090 mean_k_ = nr_k; 00091 } 00092 00094 inline int 00095 getMeanK () 00096 { 00097 return (mean_k_); 00098 } 00099 00106 inline void 00107 setStddevMulThresh (double std_mul) 00108 { 00109 std_mul_ = std_mul; 00110 } 00111 00113 inline double 00114 getStddevMulThresh () 00115 { 00116 return (std_mul_); 00117 } 00118 00122 inline void 00123 setNegative (bool negative) 00124 { 00125 negative_ = negative; 00126 } 00127 00131 inline bool 00132 getNegative () 00133 { 00134 return (negative_); 00135 } 00136 00137 protected: 00139 int mean_k_; 00140 00143 double std_mul_; 00144 00146 KdTreePtr tree_; 00147 00149 bool negative_; 00150 00154 void 00155 applyFilter (PointCloud &output); 00156 }; 00157 00168 template<> 00169 class PCL_EXPORTS StatisticalOutlierRemoval<sensor_msgs::PointCloud2> : public Filter<sensor_msgs::PointCloud2> 00170 { 00171 using Filter<sensor_msgs::PointCloud2>::filter_name_; 00172 using Filter<sensor_msgs::PointCloud2>::getClassName; 00173 00174 using Filter<sensor_msgs::PointCloud2>::removed_indices_; 00175 using Filter<sensor_msgs::PointCloud2>::extract_removed_indices_; 00176 00177 typedef pcl::search::Search<pcl::PointXYZ> KdTree; 00178 typedef pcl::search::Search<pcl::PointXYZ>::Ptr KdTreePtr; 00179 00180 typedef sensor_msgs::PointCloud2 PointCloud2; 00181 typedef PointCloud2::Ptr PointCloud2Ptr; 00182 typedef PointCloud2::ConstPtr PointCloud2ConstPtr; 00183 00184 public: 00186 StatisticalOutlierRemoval (bool extract_removed_indices = false) : 00187 Filter<sensor_msgs::PointCloud2>::Filter (extract_removed_indices), mean_k_ (2), 00188 std_mul_ (0.0), tree_ (), negative_ (false) 00189 { 00190 filter_name_ = "StatisticalOutlierRemoval"; 00191 } 00192 00196 inline void 00197 setMeanK (int nr_k) 00198 { 00199 mean_k_ = nr_k; 00200 } 00201 00203 inline int 00204 getMeanK () 00205 { 00206 return (mean_k_); 00207 } 00208 00215 inline void 00216 setStddevMulThresh (double std_mul) 00217 { 00218 std_mul_ = std_mul; 00219 } 00220 00222 inline double 00223 getStddevMulThresh () 00224 { 00225 return (std_mul_); 00226 } 00227 00231 inline void 00232 setNegative (bool negative) 00233 { 00234 negative_ = negative; 00235 } 00236 00241 inline bool 00242 getNegative () 00243 { 00244 return (negative_); 00245 } 00246 00247 protected: 00249 int mean_k_; 00250 00254 double std_mul_; 00255 00257 KdTreePtr tree_; 00258 00260 bool negative_; 00261 00262 void 00263 applyFilter (PointCloud2 &output); 00264 }; 00265 } 00266 00267 #endif //#ifndef PCL_FILTERS_STATISTICALOUTLIERREMOVAL_H_
1.8.0