Point Cloud Library (PCL)  1.8.1
correspondence_rejection_organized_boundary.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009-2012, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  * Copyright (c) Alexandru-Eugen Ichim
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above
18  * copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided
20  * with the distribution.
21  * * Neither the name of the copyright holder(s) nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef PCL_REGISTRATION_CORRESPONDENCE_REJECTION_ORGANIZED_BOUNDARY_H_
40 #define PCL_REGISTRATION_CORRESPONDENCE_REJECTION_ORGANIZED_BOUNDARY_H_
41 
42 #include <pcl/registration/correspondence_rejection.h>
43 
44 
45 namespace pcl
46 {
47  namespace registration
48  {
49  /**
50  * @brief The CorrespondenceRejectionOrganizedBoundary class implements a simple correspondence rejection measure.
51  * For each pair of points in correspondence, it checks whether they are on the boundary of a silhouette. This is
52  * done by counting the number of NaN dexels in a window around the points (the threshold and window size can be set
53  * by the user).
54  * \note Both the source and the target clouds need to be organized, otherwise all the correspondences will be rejected.
55  *
56  * \author Alexandru E. Ichim
57  * \ingroup registration
58  */
60  {
61  public:
62  /** @brief Empty constructor. */
64  : boundary_nans_threshold_ (8)
65  , window_size_ (5)
66  , depth_step_threshold_ (0.025f)
67  , data_container_ ()
68  { }
69 
70  void
71  getRemainingCorrespondences (const pcl::Correspondences& original_correspondences,
72  pcl::Correspondences& remaining_correspondences);
73 
74  inline void
76  { boundary_nans_threshold_ = val; }
77 
78 
79  template <typename PointT> inline void
81  {
82  if (!data_container_)
83  data_container_.reset (new pcl::registration::DataContainer<PointT>);
84  boost::static_pointer_cast<pcl::registration::DataContainer<PointT> > (data_container_)->setInputSource (cloud);
85  }
86 
87  template <typename PointT> inline void
89  {
90  if (!data_container_)
91  data_container_.reset (new pcl::registration::DataContainer<PointT>);
92  boost::static_pointer_cast<pcl::registration::DataContainer<PointT> > (data_container_)->setInputTarget (cloud);
93  }
94 
95  /** \brief See if this rejector requires source points */
96  bool
98  { return (true); }
99 
100  /** \brief Blob method for setting the source cloud */
101  void
103  {
105  fromPCLPointCloud2 (*cloud2, *cloud);
106  setInputSource<PointXYZ> (cloud);
107  }
108 
109  /** \brief See if this rejector requires a target cloud */
110  bool
112  { return (true); }
113 
114  /** \brief Method for setting the target cloud */
115  void
117  {
119  fromPCLPointCloud2 (*cloud2, *cloud);
120  setInputTarget<PointXYZ> (cloud);
121  }
122 
123  virtual bool
124  updateSource (const Eigen::Matrix4d &)
125  { return (true); }
126 
127  protected:
128 
129  /** \brief Apply the rejection algorithm.
130  * \param[out] correspondences the set of resultant correspondences.
131  */
132  inline void
134  { getRemainingCorrespondences (*input_correspondences_, correspondences); }
135 
139 
140  typedef boost::shared_ptr<pcl::registration::DataContainerInterface> DataContainerPtr;
142  };
143  }
144 }
145 
146 #include <pcl/registration/impl/correspondence_rejection_organized_boundary.hpp>
147 
148 
149 #endif /* PCL_REGISTRATION_CORRESPONDENCE_REJECTION_ORGANIZED_BOUNDARY_H_ */
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map.
Definition: conversions.h:169
DataContainer is a container for the input and target point clouds and implements the interface to co...
boost::shared_ptr< pcl::registration::DataContainerInterface > DataContainerPtr
void setInputSource(const typename pcl::PointCloud< PointT >::ConstPtr &cloud)
void setInputTarget(const typename pcl::PointCloud< PointT >::ConstPtr &cloud)
CorrespondenceRejector represents the base class for correspondence rejection methods
void applyRejection(pcl::Correspondences &correspondences)
Apply the rejection algorithm.
void setTargetPoints(pcl::PCLPointCloud2::ConstPtr cloud2)
Method for setting the target cloud.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
boost::shared_ptr< ::pcl::PCLPointCloud2 const > ConstPtr
bool requiresSourcePoints() const
See if this rejector requires source points.
void setSourcePoints(pcl::PCLPointCloud2::ConstPtr cloud2)
Blob method for setting the source cloud.
bool requiresTargetPoints() const
See if this rejector requires a target cloud.
PointCloud represents the base class in PCL for storing collections of 3D points.
The CorrespondenceRejectionOrganizedBoundary class implements a simple correspondence rejection measu...