Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shot_omp.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2009, 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 
37 #ifndef PCL_SHOT_OMP_H_
38 #define PCL_SHOT_OMP_H_
39 
40 #include <pcl/point_types.h>
41 #include <pcl/features/feature.h>
42 #include <pcl/features/shot.h>
43 
44 namespace pcl
45 {
64  template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT352, typename PointRFT = pcl::ReferenceFrame>
65  class SHOTEstimationOMP : public SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>
66  {
67  public:
86 
89 
91  SHOTEstimationOMP (unsigned int nr_threads = - 1) : SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT> (), threads_ ()
92  {
93  setNumberOfThreads (nr_threads);
94  }
95 
99  inline void
100  setNumberOfThreads (unsigned int nr_threads)
101  {
102  if (nr_threads == 0)
103  nr_threads = 1;
104  threads_ = nr_threads;
105  }
106 
107  protected:
108 
114  void
115  computeFeature (PointCloudOut &output);
116 
118  bool
119  initCompute ();
120 
122  int threads_;
123  };
124 
125  template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT1344, typename PointRFT = pcl::ReferenceFrame>
126  class SHOTColorEstimationOMP : public SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>
127  {
128  public:
140  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::descLength_;
141  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::nr_grid_sector_;
142  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::nr_shape_bins_;
143  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::sqradius_;
144  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius3_4_;
145  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius1_4_;
146  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius1_2_;
147  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::b_describe_shape_;
148  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::b_describe_color_;
149  using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::nr_color_bins_;
150 
153 
155  SHOTColorEstimationOMP (bool describe_shape = true,
156  bool describe_color = true,
157  unsigned int nr_threads = - 1)
158  : SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT> (describe_shape, describe_color), threads_ ()
159  {
160  setNumberOfThreads (nr_threads);
161  }
162 
166  inline void
167  setNumberOfThreads (unsigned int nr_threads)
168  {
169  if (nr_threads == 0)
170  nr_threads = 1;
171  threads_ = nr_threads;
172  }
173 
174  protected:
175 
181  void
182  computeFeature (PointCloudOut &output);
183 
185  bool
186  initCompute ();
187 
189  int threads_;
190  };
191 
192  template <typename PointInT, typename PointNT, typename PointRFT>
193  class PCL_DEPRECATED_CLASS (SHOTEstimationOMP, "SHOTEstimationOMP<..., pcl::SHOT, ...> IS DEPRECATED, USE SHOTEstimationOMP<..., pcl::SHOT352, ...> INSTEAD")
194  <PointInT, PointNT, pcl::SHOT, PointRFT>
195  : public SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT>
196  {
197  public:
198  using Feature<PointInT, pcl::SHOT>::feature_name_;
199  using Feature<PointInT, pcl::SHOT>::getClassName;
200  using Feature<PointInT, pcl::SHOT>::input_;
201  using Feature<PointInT, pcl::SHOT>::indices_;
202  using Feature<PointInT, pcl::SHOT>::k_;
203  using Feature<PointInT, pcl::SHOT>::search_parameter_;
204  using Feature<PointInT, pcl::SHOT>::search_radius_;
205  using Feature<PointInT, pcl::SHOT>::surface_;
206  using Feature<PointInT, pcl::SHOT>::fake_surface_;
207  using FeatureFromNormals<PointInT, PointNT, pcl::SHOT>::normals_;
208  using FeatureWithLocalReferenceFrames<PointInT, PointRFT>::frames_;
209  using SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT>::descLength_;
210  using SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT>::nr_grid_sector_;
211  using SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT>::nr_shape_bins_;
212  using SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT>::sqradius_;
213  using SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT>::radius3_4_;
214  using SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT>::radius1_4_;
215  using SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT>::radius1_2_;
216 
219 
221  SHOTEstimationOMP (unsigned int nr_threads = - 1, int nr_shape_bins = 10)
222  : SHOTEstimation<PointInT, PointNT, pcl::SHOT, PointRFT> (nr_shape_bins), threads_ ()
223  {
224  setNumberOfThreads (nr_threads);
225  }
226 
230  inline void
231  setNumberOfThreads (unsigned int nr_threads)
232  {
233  if (nr_threads == 0)
234  nr_threads = 1;
235  threads_ = nr_threads;
236  }
237 
238  protected:
239 
245  void
246  computeFeature (PointCloudOut &output);
247 
249  bool
250  initCompute ();
251 
253  int threads_;
254  };
255 
256  template <typename PointNT, typename PointRFT>
257  class PCL_DEPRECATED_CLASS (SHOTEstimationOMP, "SHOTEstimationOMP<pcl::PointXYZRGBA,...,pcl::SHOT,...> IS DEPRECATED, USE SHOTEstimationOMP<pcl::PointXYZRGBA,...,pcl::SHOT352,...> FOR SHAPE AND SHOTColorEstimationOMP<pcl::PointXYZRGBA,...,pcl::SHOT1344,...> FOR SHAPE+COLOR INSTEAD")
258  <pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>
259  : public SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>
260  {
261  public:
262  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::feature_name_;
263  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::getClassName;
264  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::input_;
265  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::indices_;
266  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::k_;
267  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::search_parameter_;
268  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::search_radius_;
269  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::surface_;
270  using FeatureFromNormals<pcl::PointXYZRGBA, PointNT, pcl::SHOT>::normals_;
271  using FeatureWithLocalReferenceFrames<pcl::PointXYZRGBA, PointRFT>::frames_;
272  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::descLength_;
273  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::nr_grid_sector_;
274  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::nr_shape_bins_;
275  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::sqradius_;
276  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::radius3_4_;
277  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::radius1_4_;
278  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::radius1_2_;
279  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::b_describe_shape_;
280  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::b_describe_color_;
281  using SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT>::nr_color_bins_;
282 
285 
287  SHOTEstimationOMP (bool describeShape = true,
288  bool describeColor = false,
289  unsigned int nr_threads = - 1,
290  const int nr_shape_bins = 10,
291  const int nr_color_bins = 30)
292  : SHOTEstimation<pcl::PointXYZRGBA, PointNT, pcl::SHOT, PointRFT> (describeShape, describeColor, nr_shape_bins, nr_color_bins),
293  threads_ ()
294  {
295  setNumberOfThreads (nr_threads);
296  }
297 
301  inline void
302  setNumberOfThreads (unsigned int nr_threads)
303  {
304  if (nr_threads == 0)
305  nr_threads = 1;
306  threads_ = nr_threads;
307  }
308 
309  private:
310 
316  void
317  computeFeature (PointCloudOut &output);
318 
320  int threads_;
321  };
322 }
323 
324 #endif //#ifndef PCL_SHOT_OMP_H_
325 
326