00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2012-, Open Perception, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of the copyright holder(s) nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 */ 00037 00038 00039 #ifndef PCL_FILTERS_FRUSTUM_CULLING_H_ 00040 #define PCL_FILTERS_FRUSTUM_CULLING_H_ 00041 00042 #include <pcl/point_types.h> 00043 #include <pcl/filters/filter_indices.h> 00044 #include <pcl/common/transforms.h> 00045 #include <pcl/common/eigen.h> 00046 00047 namespace pcl 00048 { 00077 template <typename PointT> 00078 class FrustumCulling : public FilterIndices<PointT> 00079 { 00080 typedef typename Filter<PointT>::PointCloud PointCloud; 00081 typedef typename PointCloud::Ptr PointCloudPtr; 00082 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00083 00084 public: 00085 00086 typedef boost::shared_ptr< FrustumCulling<PointT> > Ptr; 00087 typedef boost::shared_ptr< const FrustumCulling<PointT> > ConstPtr; 00088 00089 00090 using Filter<PointT>::getClassName; 00091 00092 FrustumCulling (bool extract_removed_indices = false) 00093 : FilterIndices<PointT>::FilterIndices (extract_removed_indices) 00094 , camera_pose_ (Eigen::Matrix4f::Identity ()) 00095 , hfov_ (60.0f) 00096 , vfov_ (60.0f) 00097 , np_dist_ (0.1f) 00098 , fp_dist_ (5.0f) 00099 { 00100 filter_name_ = "FrustumCulling"; 00101 } 00102 00121 void 00122 setCameraPose (const Eigen::Matrix4f& camera_pose) 00123 { 00124 camera_pose_ = camera_pose; 00125 } 00126 00128 Eigen::Matrix4f 00129 getCameraPose () const 00130 { 00131 return (camera_pose_); 00132 } 00133 00137 void 00138 setHorizontalFOV (float hfov) 00139 { 00140 hfov_ = hfov; 00141 } 00142 00144 float 00145 getHorizontalFOV () const 00146 { 00147 return (hfov_); 00148 } 00149 00153 void 00154 setVerticalFOV (float vfov) 00155 { 00156 vfov_ = vfov; 00157 } 00158 00160 float 00161 getVerticalFOV () const 00162 { 00163 return (vfov_); 00164 } 00165 00169 void 00170 setNearPlaneDistance (float np_dist) 00171 { 00172 np_dist_ = np_dist; 00173 } 00174 00176 float 00177 getNearPlaneDistance () const 00178 { 00179 return (np_dist_); 00180 } 00181 00185 void 00186 setFarPlaneDistance (float fp_dist) 00187 { 00188 fp_dist_ = fp_dist; 00189 } 00190 00192 float 00193 getFarPlaneDistance () const 00194 { 00195 return (fp_dist_); 00196 } 00197 00198 protected: 00199 using PCLBase<PointT>::input_; 00200 using PCLBase<PointT>::indices_; 00201 using Filter<PointT>::filter_name_; 00202 using FilterIndices<PointT>::negative_; 00203 using FilterIndices<PointT>::keep_organized_; 00204 using FilterIndices<PointT>::user_filter_value_; 00205 using FilterIndices<PointT>::extract_removed_indices_; 00206 using FilterIndices<PointT>::removed_indices_; 00207 00211 void 00212 applyFilter (PointCloud &output); 00213 00217 void 00218 applyFilter (std::vector<int> &indices); 00219 00220 private: 00221 00223 Eigen::Matrix4f camera_pose_; 00225 float hfov_; 00227 float vfov_; 00229 float np_dist_; 00231 float fp_dist_; 00232 00233 public: 00234 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00235 }; 00236 } 00237 00238 #endif