Point Cloud Library (PCL)  1.7.0
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  virtual bool
96  updateSource (const Eigen::Matrix4d &)
97  { return (true); }
98 
99  protected:
100 
101  /** \brief Apply the rejection algorithm.
102  * \param[out] correspondences the set of resultant correspondences.
103  */
104  inline void
106  { getRemainingCorrespondences (*input_correspondences_, correspondences); }
107 
111 
112  typedef boost::shared_ptr<pcl::registration::DataContainerInterface> DataContainerPtr;
114  };
115  }
116 }
117 
118 #include <pcl/registration/impl/correspondence_rejection_organized_boundary.hpp>
119 
120 
121 #endif /* PCL_REGISTRATION_CORRESPONDENCE_REJECTION_ORGANIZED_BOUNDARY_H_ */