Point Cloud Library (PCL)  1.10.0-dev
iss_3d.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2010, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  */
35 
36 #pragma once
37 
38 #include <pcl/keypoints/keypoint.h>
39 
40 namespace pcl
41 {
42  /** \brief ISSKeypoint3D detects the Intrinsic Shape Signatures keypoints for a given
43  * point cloud. This class is based on a particular implementation made by Federico
44  * Tombari and Samuele Salti and it has been explicitly adapted to PCL.
45  *
46  * For more information about the original ISS detector, see:
47  *
48  *\par
49  * Yu Zhong, “Intrinsic shape signatures: A shape descriptor for 3D object recognition,”
50  * Computer Vision Workshops (ICCV Workshops), 2009 IEEE 12th International Conference on ,
51  * vol., no., pp.689-696, Sept. 27 2009-Oct. 4 2009
52  *
53  * Code example:
54  *
55  * \code
56  * pcl::PointCloud<pcl::PointXYZRGBA>::Ptr model (new pcl::PointCloud<pcl::PointXYZRGBA> ());;
57  * pcl::PointCloud<pcl::PointXYZRGBA>::Ptr model_keypoints (new pcl::PointCloud<pcl::PointXYZRGBA> ());
58  * pcl::search::KdTree<pcl::PointXYZRGBA>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGBA> ());
59  *
60  * // Fill in the model cloud
61  *
62  * double model_resolution;
63  *
64  * // Compute model_resolution
65  *
66  * pcl::ISSKeypoint3D<pcl::PointXYZRGBA, pcl::PointXYZRGBA> iss_detector;
67  *
68  * iss_detector.setSearchMethod (tree);
69  * iss_detector.setSalientRadius (6 * model_resolution);
70  * iss_detector.setNonMaxRadius (4 * model_resolution);
71  * iss_detector.setThreshold21 (0.975);
72  * iss_detector.setThreshold32 (0.975);
73  * iss_detector.setMinNeighbors (5);
74  * iss_detector.setNumberOfThreads (4);
75  * iss_detector.setInputCloud (model);
76  * iss_detector.compute (*model_keypoints);
77  * \endcode
78  *
79  * \author Gioia Ballin
80  * \ingroup keypoints
81  */
82 
83  template <typename PointInT, typename PointOutT, typename NormalT = pcl::Normal>
84  class ISSKeypoint3D : public Keypoint<PointInT, PointOutT>
85  {
86  public:
89 
92 
94  using PointCloudNPtr = typename PointCloudN::Ptr;
96 
99 
107 
108  /** \brief Constructor.
109  * \param[in] salient_radius the radius of the spherical neighborhood used to compute the scatter matrix.
110  */
111  ISSKeypoint3D (double salient_radius = 0.0001)
112  : salient_radius_ (salient_radius)
113  , non_max_radius_ (0.0)
114  , normal_radius_ (0.0)
115  , border_radius_ (0.0)
116  , gamma_21_ (0.975)
117  , gamma_32_ (0.975)
118  , third_eigen_value_ (nullptr)
119  , edge_points_ (nullptr)
120  , min_neighbors_ (5)
121  , normals_ (new pcl::PointCloud<NormalT>)
122  , angle_threshold_ (static_cast<float> (M_PI) / 2.0f)
123  , threads_ (0)
124  {
125  name_ = "ISSKeypoint3D";
127  }
128 
129  /** \brief Destructor. */
131  {
132  delete[] third_eigen_value_;
133  delete[] edge_points_;
134  }
135 
136  /** \brief Set the radius of the spherical neighborhood used to compute the scatter matrix.
137  * \param[in] salient_radius the radius of the spherical neighborhood
138  */
139  void
140  setSalientRadius (double salient_radius);
141 
142  /** \brief Set the radius for the application of the non maxima supression algorithm.
143  * \param[in] non_max_radius the non maxima suppression radius
144  */
145  void
146  setNonMaxRadius (double non_max_radius);
147 
148  /** \brief Set the radius used for the estimation of the surface normals of the input cloud. If the radius is
149  * too large, the temporal performances of the detector may degrade significantly.
150  * \param[in] normal_radius the radius used to estimate surface normals
151  */
152  void
153  setNormalRadius (double normal_radius);
154 
155  /** \brief Set the radius used for the estimation of the boundary points. If the radius is too large,
156  * the temporal performances of the detector may degrade significantly.
157  * \param[in] border_radius the radius used to compute the boundary points
158  */
159  void
160  setBorderRadius (double border_radius);
161 
162  /** \brief Set the upper bound on the ratio between the second and the first eigenvalue.
163  * \param[in] gamma_21 the upper bound on the ratio between the second and the first eigenvalue
164  */
165  void
166  setThreshold21 (double gamma_21);
167 
168  /** \brief Set the upper bound on the ratio between the third and the second eigenvalue.
169  * \param[in] gamma_32 the upper bound on the ratio between the third and the second eigenvalue
170  */
171  void
172  setThreshold32 (double gamma_32);
173 
174  /** \brief Set the minimum number of neighbors that has to be found while applying the non maxima suppression algorithm.
175  * \param[in] min_neighbors the minimum number of neighbors required
176  */
177  void
178  setMinNeighbors (int min_neighbors);
179 
180  /** \brief Set the normals if pre-calculated normals are available.
181  * \param[in] normals the given cloud of normals
182  */
183  void
184  setNormals (const PointCloudNConstPtr &normals);
185 
186  /** \brief Set the decision boundary (angle threshold) that marks points as boundary or regular.
187  * (default \f$\pi / 2.0\f$)
188  * \param[in] angle the angle threshold
189  */
190  inline void
191  setAngleThreshold (float angle)
192  {
193  angle_threshold_ = angle;
194  }
195 
196  /** \brief Initialize the scheduler and set the number of threads to use.
197  * \param[in] nr_threads the number of hardware threads to use (0 sets the value back to automatic)
198  */
199  inline void
200  setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
201 
202  protected:
203 
204  /** \brief Compute the boundary points for the given input cloud.
205  * \param[in] input the input cloud
206  * \param[in] border_radius the radius used to compute the boundary points
207  * \param[in] angle_threshold the decision boundary that marks the points as boundary
208  * \return the vector of boolean values in which the information about the boundary points is stored
209  */
210  bool*
211  getBoundaryPoints (PointCloudIn &input, double border_radius, float angle_threshold);
212 
213  /** \brief Compute the scatter matrix for a point index.
214  * \param[in] current_index the index of the point
215  * \param[out] cov_m the point scatter matrix
216  */
217  void
218  getScatterMatrix (const int &current_index, Eigen::Matrix3d &cov_m);
219 
220  /** \brief Perform the initial checks before computing the keypoints.
221  * \return true if all the checks are passed, false otherwise
222  */
223  bool
224  initCompute () override;
225 
226  /** \brief Detect the keypoints by performing the EVD of the scatter matrix.
227  * \param[out] output the resultant cloud of keypoints
228  */
229  void
230  detectKeypoints (PointCloudOut &output) override;
231 
232 
233  /** \brief The radius of the spherical neighborhood used to compute the scatter matrix.*/
235 
236  /** \brief The non maxima suppression radius. */
238 
239  /** \brief The radius used to compute the normals of the input cloud. */
241 
242  /** \brief The radius used to compute the boundary points of the input cloud. */
244 
245  /** \brief The upper bound on the ratio between the second and the first eigenvalue returned by the EVD. */
246  double gamma_21_;
247 
248  /** \brief The upper bound on the ratio between the third and the second eigenvalue returned by the EVD. */
249  double gamma_32_;
250 
251  /** \brief Store the third eigen value associated to each point in the input cloud. */
253 
254  /** \brief Store the information about the boundary points of the input cloud. */
256 
257  /** \brief Minimum number of neighbors that has to be found while applying the non maxima suppression algorithm. */
259 
260  /** \brief The cloud of normals related to the input surface. */
262 
263  /** \brief The decision boundary (angle threshold) that marks points as boundary or regular. (default \f$\pi / 2.0\f$) */
265 
266  /** \brief The number of threads that has to be used by the scheduler. */
267  unsigned int threads_;
268 
269  };
270 
271 }
272 
273 #include <pcl/keypoints/impl/iss_3d.hpp>
A point structure representing normal coordinates and the surface curvature estimate.
double gamma_32_
The upper bound on the ratio between the third and the second eigenvalue returned by the EVD...
Definition: iss_3d.h:249
void setThreshold32(double gamma_32)
Set the upper bound on the ratio between the third and the second eigenvalue.
Definition: iss_3d.hpp:84
double salient_radius_
The radius of the spherical neighborhood used to compute the scatter matrix.
Definition: iss_3d.h:234
bool initCompute() override
Perform the initial checks before computing the keypoints.
Definition: iss_3d.hpp:198
shared_ptr< PointCloud< NormalT > > Ptr
Definition: point_cloud.h:415
void setSalientRadius(double salient_radius)
Set the radius of the spherical neighborhood used to compute the scatter matrix.
Definition: iss_3d.hpp:49
void getScatterMatrix(const int &current_index, Eigen::Matrix3d &cov_m)
Compute the scatter matrix for a point index.
Definition: iss_3d.hpp:148
void setAngleThreshold(float angle)
Set the decision boundary (angle threshold) that marks points as boundary or regular.
Definition: iss_3d.h:191
void setBorderRadius(double border_radius)
Set the radius used for the estimation of the boundary points.
Definition: iss_3d.hpp:70
std::string name_
The key point detection method&#39;s name.
Definition: keypoint.h:169
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
typename OctreeSearchIn::Ptr OctreeSearchInPtr
Definition: iss_3d.h:98
void setNormals(const PointCloudNConstPtr &normals)
Set the normals if pre-calculated normals are available.
Definition: iss_3d.hpp:98
double search_radius_
The nearest neighbors search radius for each point.
Definition: keypoint.h:187
void setThreshold21(double gamma_21)
Set the upper bound on the ratio between the second and the first eigenvalue.
Definition: iss_3d.hpp:77
shared_ptr< const ISSKeypoint3D< PointInT, PointOutT, NormalT > > ConstPtr
Definition: iss_3d.h:88
double normal_radius_
The radius used to compute the normals of the input cloud.
Definition: iss_3d.h:240
void detectKeypoints(PointCloudOut &output) override
Detect the keypoints by performing the EVD of the scatter matrix.
Definition: iss_3d.hpp:292
typename PointCloudN::ConstPtr PointCloudNConstPtr
Definition: iss_3d.h:95
bool * edge_points_
Store the information about the boundary points of the input cloud.
Definition: iss_3d.h:255
double gamma_21_
The upper bound on the ratio between the second and the first eigenvalue returned by the EVD...
Definition: iss_3d.h:246
void setMinNeighbors(int min_neighbors)
Set the minimum number of neighbors that has to be found while applying the non maxima suppression al...
Definition: iss_3d.hpp:91
Keypoint represents the base class for key points.
Definition: keypoint.h:48
unsigned int threads_
The number of threads that has to be used by the scheduler.
Definition: iss_3d.h:267
ISSKeypoint3D detects the Intrinsic Shape Signatures keypoints for a given point cloud.
Definition: iss_3d.h:84
PointCloudNConstPtr normals_
The cloud of normals related to the input surface.
Definition: iss_3d.h:261
bool * getBoundaryPoints(PointCloudIn &input, double border_radius, float angle_threshold)
Compute the boundary points for the given input cloud.
Definition: iss_3d.hpp:105
~ISSKeypoint3D()
Destructor.
Definition: iss_3d.h:130
int min_neighbors_
Minimum number of neighbors that has to be found while applying the non maxima suppression algorithm...
Definition: iss_3d.h:258
shared_ptr< OctreePointCloudSearch< PointT, LeafContainerT, BranchContainerT > > Ptr
Definition: octree_search.h:68
typename Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: iss_3d.h:91
typename PointCloudN::Ptr PointCloudNPtr
Definition: iss_3d.h:94
void setNormalRadius(double normal_radius)
Set the radius used for the estimation of the surface normals of the input cloud. ...
Definition: iss_3d.hpp:63
shared_ptr< ISSKeypoint3D< PointInT, PointOutT, NormalT > > Ptr
Definition: iss_3d.h:87
float angle_threshold_
The decision boundary (angle threshold) that marks points as boundary or regular. ...
Definition: iss_3d.h:264
void setNonMaxRadius(double non_max_radius)
Set the radius for the application of the non maxima supression algorithm.
Definition: iss_3d.hpp:56
Octree pointcloud search class
Definition: octree_search.h:56
double non_max_radius_
The non maxima suppression radius.
Definition: iss_3d.h:237
shared_ptr< const PointCloud< NormalT > > ConstPtr
Definition: point_cloud.h:416
double * third_eigen_value_
Store the third eigen value associated to each point in the input cloud.
Definition: iss_3d.h:252
typename Keypoint< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition: iss_3d.h:90
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: pcl_macros.h:90
double border_radius_
The radius used to compute the boundary points of the input cloud.
Definition: iss_3d.h:243
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition: iss_3d.h:200
ISSKeypoint3D(double salient_radius=0.0001)
Constructor.
Definition: iss_3d.h:111