Point Cloud Library (PCL)  1.9.1-dev
shot_lrf_omp.hpp
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012, 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  * $Id$
38  */
39 
40 #ifndef PCL_FEATURES_IMPL_SHOT_LRF_OMP_H_
41 #define PCL_FEATURES_IMPL_SHOT_LRF_OMP_H_
42 
43 #include <utility>
44 #include <pcl/features/shot_lrf_omp.h>
45 #include <pcl/features/shot_lrf.h>
46 
47 //////////////////////////////////////////////////////////////////////////////////////////////
48 template<typename PointInT, typename PointOutT> void
50 {
51  if (nr_threads == 0)
52 #ifdef _OPENMP
53  threads_ = omp_get_num_procs();
54 #else
55  threads_ = 1;
56 #endif
57  else
58  threads_ = nr_threads;
59 }
60 
61 //////////////////////////////////////////////////////////////////////////////////////////////
62 template<typename PointInT, typename PointOutT> void
64 {
65  //check whether used with search radius or search k-neighbors
66  if (this->getKSearch () != 0)
67  {
68  PCL_ERROR(
69  "[pcl::%s::computeFeature] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n",
70  getClassName().c_str ());
71  return;
72  }
73  tree_->setSortedResults (true);
74 
75  int data_size = static_cast<int> (indices_->size ());
76 #ifdef _OPENMP
77 #pragma omp parallel for num_threads(threads_)
78 #endif
79  for (int i = 0; i < data_size; ++i)
80  {
81  // point result
82  Eigen::Matrix3f rf;
83  PointOutT& output_rf = output[i];
84 
85  //output_rf.confidence = getLocalRF ((*indices_)[i], rf);
86  //if (output_rf.confidence == std::numeric_limits<float>::max ())
87 
88  std::vector<int> n_indices;
89  std::vector<float> n_sqr_distances;
90  this->searchForNeighbors ((*indices_)[i], search_parameter_, n_indices, n_sqr_distances);
91  if (getLocalRF ((*indices_)[i], rf) == std::numeric_limits<float>::max ())
92  {
93  output.is_dense = false;
94  }
95 
96  for (int d = 0; d < 3; ++d)
97  {
98  output_rf.x_axis[d] = rf.row (0)[d];
99  output_rf.y_axis[d] = rf.row (1)[d];
100  output_rf.z_axis[d] = rf.row (2)[d];
101  }
102  }
103 
104 }
105 
106 #define PCL_INSTANTIATE_SHOTLocalReferenceFrameEstimationOMP(T,OutT) template class PCL_EXPORTS pcl::SHOTLocalReferenceFrameEstimationOMP<T,OutT>;
107 
108 #endif // PCL_FEATURES_IMPL_SHOT_LRF_H_
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
void computeFeature(PointCloudOut &output) override
Feature estimation method.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields)...
Definition: point_cloud.h:402