Point Cloud Library (PCL)  1.15.1-dev
shot_omp.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  *
38  */
39 
40 #pragma once
41 
42 #include <pcl/point_types.h>
43 #include <pcl/features/feature.h>
44 #include <pcl/features/shot.h>
45 
46 namespace pcl
47 {
48  /** \brief SHOTEstimationOMP estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given point cloud dataset
49  * containing points and normals, in parallel, using the OpenMP standard.
50  *
51  * The suggested PointOutT is pcl::SHOT352.
52  *
53  * \note If you use this code in any academic work, please cite:
54  *
55  * - F. Tombari, S. Salti, L. Di Stefano
56  * Unique Signatures of Histograms for Local Surface Description.
57  * In Proceedings of the 11th European Conference on Computer Vision (ECCV),
58  * Heraklion, Greece, September 5-11 2010.
59  * - F. Tombari, S. Salti, L. Di Stefano
60  * A Combined Texture-Shape Descriptor For Enhanced 3D Feature Matching.
61  * In Proceedings of the 18th International Conference on Image Processing (ICIP),
62  * Brussels, Belgium, September 11-14 2011.
63  *
64  * \author Samuele Salti
65  * \ingroup features
66  */
67 
68  template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT352, typename PointRFT = pcl::ReferenceFrame>
69  class SHOTEstimationOMP : public SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>
70  {
71  public:
72  using Ptr = shared_ptr<SHOTEstimationOMP<PointInT, PointNT, PointOutT, PointRFT> >;
73  using ConstPtr = shared_ptr<const SHOTEstimationOMP<PointInT, PointNT, PointOutT, PointRFT> >;
93 
96 
97  /** \brief Empty constructor.
98  * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
99  * \param chunk_size PCL will use dynamic scheduling with this chunk size. Setting it too low will lead to more parallelization overhead. Setting it too high will lead to a worse balancing between the threads.
100  */
101  SHOTEstimationOMP (unsigned int nr_threads = 0, int chunk_size = 256)
102  : SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT> (), chunk_size_(chunk_size)
103  {
104  setNumberOfThreads(nr_threads);
105  };
106 
107  /** \brief Initialize the scheduler and set the number of threads to use.
108  * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
109  */
110  void
111  setNumberOfThreads (unsigned int nr_threads = 0);
112 
113  protected:
114 
115  /** \brief Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by
116  * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
117  * setSearchMethod ()
118  * \param output the resultant point cloud model dataset that contains the SHOT feature estimates
119  */
120  void
121  computeFeature (PointCloudOut &output) override;
122 
123  /** \brief This method should get called before starting the actual computation. */
124  bool
125  initCompute () override;
126 
127  /** \brief The number of threads the scheduler should use. */
128  unsigned int threads_;
129 
130  /** \brief Chunk size for (dynamic) scheduling. */
132  };
133 
134  /** \brief SHOTColorEstimationOMP estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given point cloud dataset
135  * containing points, normals and colors, in parallel, using the OpenMP standard.
136  *
137  * The suggested PointOutT is pcl::SHOT1344.
138  *
139  * \note If you use this code in any academic work, please cite:
140  *
141  * - F. Tombari, S. Salti, L. Di Stefano
142  * Unique Signatures of Histograms for Local Surface Description.
143  * In Proceedings of the 11th European Conference on Computer Vision (ECCV),
144  * Heraklion, Greece, September 5-11 2010.
145  * - F. Tombari, S. Salti, L. Di Stefano
146  * A Combined Texture-Shape Descriptor For Enhanced 3D Feature Matching.
147  * In Proceedings of the 18th International Conference on Image Processing (ICIP),
148  * Brussels, Belgium, September 11-14 2011.
149  *
150  * \author Samuele Salti
151  * \ingroup features
152  */
153 
154  template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT1344, typename PointRFT = pcl::ReferenceFrame>
155  class SHOTColorEstimationOMP : public SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>
156  {
157  public:
158  using Ptr = shared_ptr<SHOTColorEstimationOMP<PointInT, PointNT, PointOutT, PointRFT> >;
159  using ConstPtr = shared_ptr<const SHOTColorEstimationOMP<PointInT, PointNT, PointOutT, PointRFT> >;
182 
185 
186  /** \brief Empty constructor.
187  * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
188  * \param chunk_size PCL will use dynamic scheduling with this chunk size. Setting it too low will lead to more parallelization overhead. Setting it too high will lead to a worse balancing between the threads.
189  */
190  SHOTColorEstimationOMP (bool describe_shape = true,
191  bool describe_color = true,
192  unsigned int nr_threads = 0,
193  int chunk_size = 64)
194  : SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT> (describe_shape, describe_color),
195  chunk_size_(chunk_size)
196  {
197  setNumberOfThreads(nr_threads);
198  }
199 
200  /** \brief Initialize the scheduler and set the number of threads to use.
201  * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
202  */
203  void
204  setNumberOfThreads (unsigned int nr_threads = 0);
205 
206  protected:
207 
208  /** \brief Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by
209  * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
210  * setSearchMethod ()
211  * \param output the resultant point cloud model dataset that contains the SHOT feature estimates
212  */
213  void
214  computeFeature (PointCloudOut &output) override;
215 
216  /** \brief This method should get called before starting the actual computation. */
217  bool
218  initCompute () override;
219 
220  /** \brief The number of threads the scheduler should use. */
221  unsigned int threads_;
222 
223  /** \brief Chunk size for (dynamic) scheduling. */
225  };
226 
227 }
228 
229 #ifdef PCL_NO_PRECOMPILE
230 #include <pcl/features/impl/shot_omp.hpp>
231 #endif
Feature represents the base feature class.
Definition: feature.h:107
shared_ptr< Feature< PointInT, PointOutT > > Ptr
Definition: feature.h:114
shared_ptr< const Feature< PointInT, PointOutT > > ConstPtr
Definition: feature.h:115
FeatureWithLocalReferenceFrames provides a public interface for descriptor extractor classes which ne...
Definition: feature.h:440
SHOTColorEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a giv...
Definition: shot.h:290
SHOTColorEstimationOMP estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a ...
Definition: shot_omp.h:156
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition: shot_omp.hpp:210
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: shot_omp.h:183
unsigned int threads_
The number of threads the scheduler should use.
Definition: shot_omp.h:221
int chunk_size_
Chunk size for (dynamic) scheduling.
Definition: shot_omp.h:224
void computeFeature(PointCloudOut &output) override
Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by ...
Definition: shot_omp.hpp:224
SHOTColorEstimationOMP(bool describe_shape=true, bool describe_color=true, unsigned int nr_threads=0, int chunk_size=64)
Empty constructor.
Definition: shot_omp.h:190
bool initCompute() override
This method should get called before starting the actual computation.
Definition: shot_omp.hpp:88
SHOTEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given po...
Definition: shot.h:71
SHOTEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given po...
Definition: shot.h:213
SHOTEstimationOMP estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given...
Definition: shot_omp.h:70
unsigned int threads_
The number of threads the scheduler should use.
Definition: shot_omp.h:128
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition: shot_omp.hpp:126
bool initCompute() override
This method should get called before starting the actual computation.
Definition: shot_omp.hpp:50
void computeFeature(PointCloudOut &output) override
Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by ...
Definition: shot_omp.hpp:140
int chunk_size_
Chunk size for (dynamic) scheduling.
Definition: shot_omp.h:131
SHOTEstimationOMP(unsigned int nr_threads=0, int chunk_size=256)
Empty constructor.
Definition: shot_omp.h:101
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: shot_omp.h:94
Defines all the PCL implemented PointT point type structures.