Point Cloud Library (PCL)  1.11.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 #pragma once
40 
41 #include <pcl/registration/correspondence_rejection.h>
42 #include <pcl/memory.h> // for static_pointer_cast
43 
44 namespace pcl
45 {
46  namespace registration
47  {
48  /**
49  * @brief The CorrespondenceRejectionOrganizedBoundary class implements a simple correspondence rejection measure.
50  * For each pair of points in correspondence, it checks whether they are on the boundary of a silhouette. This is
51  * done by counting the number of NaN dexels in a window around the points (the threshold and window size can be set
52  * by the user).
53  * \note Both the source and the target clouds need to be organized, otherwise all the correspondences will be rejected.
54  *
55  * \author Alexandru E. Ichim
56  * \ingroup registration
57  */
59  {
60  public:
61  /** @brief Empty constructor. */
63  : boundary_nans_threshold_ (8)
64  , window_size_ (5)
65  , depth_step_threshold_ (0.025f)
66  { }
67 
68  void
69  getRemainingCorrespondences (const pcl::Correspondences& original_correspondences,
70  pcl::Correspondences& remaining_correspondences) override;
71 
72  inline void
74  { boundary_nans_threshold_ = val; }
75 
76 
77  template <typename PointT> inline void
79  {
80  if (!data_container_)
81  data_container_.reset (new pcl::registration::DataContainer<PointT>);
82  static_pointer_cast<pcl::registration::DataContainer<PointT> > (data_container_)->setInputSource (cloud);
83  }
84 
85  template <typename PointT> inline void
87  {
88  if (!data_container_)
89  data_container_.reset (new pcl::registration::DataContainer<PointT>);
90  static_pointer_cast<pcl::registration::DataContainer<PointT> > (data_container_)->setInputTarget (cloud);
91  }
92 
93  /** \brief See if this rejector requires source points */
94  bool
95  requiresSourcePoints () const override
96  { return (true); }
97 
98  /** \brief Blob method for setting the source cloud */
99  void
101  {
103  fromPCLPointCloud2 (*cloud2, *cloud);
104  setInputSource<PointXYZ> (cloud);
105  }
106 
107  /** \brief See if this rejector requires a target cloud */
108  bool
109  requiresTargetPoints () const override
110  { return (true); }
111 
112  /** \brief Method for setting the target cloud */
113  void
115  {
117  fromPCLPointCloud2 (*cloud2, *cloud);
118  setInputTarget<PointXYZ> (cloud);
119  }
120 
121  virtual bool
122  updateSource (const Eigen::Matrix4d &)
123  { return (true); }
124 
125  protected:
126 
127  /** \brief Apply the rejection algorithm.
128  * \param[out] correspondences the set of resultant correspondences.
129  */
130  inline void
131  applyRejection (pcl::Correspondences &correspondences) override
132  { getRemainingCorrespondences (*input_correspondences_, correspondences); }
133 
137 
140  };
141  }
142 }
143 
144 #include <pcl/registration/impl/correspondence_rejection_organized_boundary.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:181
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:429
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:430
The CorrespondenceRejectionOrganizedBoundary class implements a simple correspondence rejection measu...
void setInputTarget(const typename pcl::PointCloud< PointT >::ConstPtr &cloud)
bool requiresTargetPoints() const override
See if this rejector requires a target cloud.
void setSourcePoints(pcl::PCLPointCloud2::ConstPtr cloud2) override
Blob method for setting the source cloud.
void setTargetPoints(pcl::PCLPointCloud2::ConstPtr cloud2) override
Method for setting the target cloud.
void setInputSource(const typename pcl::PointCloud< PointT >::ConstPtr &cloud)
void applyRejection(pcl::Correspondences &correspondences) override
Apply the rejection algorithm.
void getRemainingCorrespondences(const pcl::Correspondences &original_correspondences, pcl::Correspondences &remaining_correspondences) override
Get a list of valid correspondences after rejection from the original set of correspondences.
bool requiresSourcePoints() const override
See if this rejector requires source points.
CorrespondenceRejector represents the base class for correspondence rejection methods
DataContainer is a container for the input and target point clouds and implements the interface to co...
shared_ptr< DataContainerInterface > Ptr
Defines functions, macros and traits for allocating and using memory.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
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:168
#define PCL_EXPORTS
Definition: pcl_macros.h:328
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr