Point Cloud Library (PCL)  1.8.1-dev
shadowpoints.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef PCL_FILTERS_SHADOW_POINTS_FILTER_H_
39 #define PCL_FILTERS_SHADOW_POINTS_FILTER_H_
40 
41 #include <pcl/filters/filter_indices.h>
42 #include <time.h>
43 #include <limits.h>
44 
45 namespace pcl
46 {
47  /** \brief @b ShadowPoints removes the ghost points appearing on edge discontinuties
48  *
49  * \author Aravindhan K Krishnan. This code is ported from libpointmatcher (https://github.com/ethz-asl/libpointmatcher)
50  * \ingroup filters
51  */
52  template<typename PointT, typename NormalT>
53  class ShadowPoints : public FilterIndices<PointT>
54  {
64 
66  typedef typename PointCloud::Ptr PointCloudPtr;
68  typedef typename pcl::PointCloud<NormalT>::Ptr NormalsPtr;
69 
70  public:
71 
72  typedef boost::shared_ptr< ShadowPoints<PointT, NormalT> > Ptr;
73  typedef boost::shared_ptr< const ShadowPoints<PointT, NormalT> > ConstPtr;
74 
75  /** \brief Empty constructor. */
76  ShadowPoints (bool extract_removed_indices = false) :
77  FilterIndices<PointT> (extract_removed_indices),
78  input_normals_ (),
79  threshold_ (0.1f)
80  {
81  filter_name_ = "ShadowPoints";
82  }
83 
84  /** \brief Set the normals computed on the input point cloud
85  * \param[in] normals the normals computed for the input cloud
86  */
87  inline void
88  setNormals (const NormalsPtr &normals) { input_normals_ = normals; }
89 
90  /** \brief Get the normals computed on the input point cloud */
91  inline NormalsPtr
92  getNormals () const { return (input_normals_); }
93 
94  /** \brief Set the threshold for shadow points rejection
95  * \param[in] threshold the threshold
96  */
97  inline void
98  setThreshold (float threshold) { threshold_ = threshold; }
99 
100  /** \brief Get the threshold for shadow points rejection */
101  inline float
102  getThreshold () const { return threshold_; }
103 
104  protected:
105 
106  /** \brief The normals computed at each point in the input cloud */
107  NormalsPtr input_normals_;
108 
109  /** \brief Sample of point indices into a separate PointCloud
110  * \param[out] output the resultant point cloud
111  */
112  void
113  applyFilter (PointCloud &output);
114 
115  /** \brief Sample of point indices
116  * \param[out] indices the resultant point cloud indices
117  */
118  void
119  applyFilter (std::vector<int> &indices);
120 
121  private:
122 
123  /** \brief Threshold for shadow point rejection
124  */
125  float threshold_;
126  };
127 }
128 
129 #ifdef PCL_NO_PRECOMPILE
130 #include <pcl/filters/impl/shadowpoints.hpp>
131 #endif
132 
133 #endif //#ifndef PCL_FILTERS_SHADOW_POINTS_FILTER_H_
boost::shared_ptr< ShadowPoints< PointT, NormalT > > Ptr
Definition: shadowpoints.h:72
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
PointCloud::ConstPtr PointCloudConstPtr
Definition: pcl_base.h:73
void setNormals(const NormalsPtr &normals)
Set the normals computed on the input point cloud.
Definition: shadowpoints.h:88
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
NormalsPtr getNormals() const
Get the normals computed on the input point cloud.
Definition: shadowpoints.h:92
FilterIndices represents the base class for filters that are about binary point removal.
PointCloud::Ptr PointCloudPtr
Definition: pcl_base.h:72
void applyFilter(PointCloud &output)
Sample of point indices into a separate PointCloud.
ShadowPoints(bool extract_removed_indices=false)
Empty constructor.
Definition: shadowpoints.h:76
NormalsPtr input_normals_
The normals computed at each point in the input cloud.
Definition: shadowpoints.h:107
void setThreshold(float threshold)
Set the threshold for shadow points rejection.
Definition: shadowpoints.h:98
float getThreshold() const
Get the threshold for shadow points rejection.
Definition: shadowpoints.h:102
ShadowPoints removes the ghost points appearing on edge discontinuties
Definition: shadowpoints.h:53
std::string filter_name_
The filter name.
Definition: filter.h:166
A point structure representing Euclidean xyz coordinates, and the RGB color.
boost::shared_ptr< const ShadowPoints< PointT, NormalT > > ConstPtr
Definition: shadowpoints.h:73