Point Cloud Library (PCL) 1.13.1
Loading...
Searching...
No Matches
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 <pcl/features/shot_lrf_omp.h>
44#include <pcl/features/shot_lrf.h>
45
46//////////////////////////////////////////////////////////////////////////////////////////////
47template<typename PointInT, typename PointOutT> void
49{
50 if (nr_threads == 0)
51#ifdef _OPENMP
52 threads_ = omp_get_num_procs();
53#else
54 threads_ = 1;
55#endif
56 else
57 threads_ = nr_threads;
58}
59
60//////////////////////////////////////////////////////////////////////////////////////////////
61template<typename PointInT, typename PointOutT> void
63{
64 //check whether used with search radius or search k-neighbors
65 if (this->getKSearch () != 0)
66 {
67 PCL_ERROR(
68 "[pcl::%s::computeFeature] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n",
69 getClassName().c_str ());
70 return;
71 }
72 tree_->setSortedResults (true);
73
74#pragma omp parallel for \
75 default(none) \
76 shared(output) \
77 num_threads(threads_)
78 for (std::ptrdiff_t i = 0; i < static_cast<std::ptrdiff_t> (indices_->size ()); ++i)
79 {
80 // point result
81 Eigen::Matrix3f rf;
82 PointOutT& output_rf = output[i];
83
84 //output_rf.confidence = getLocalRF ((*indices_)[i], rf);
85 //if (output_rf.confidence == std::numeric_limits<float>::max ())
86
87 pcl::Indices n_indices;
88 std::vector<float> n_sqr_distances;
89 this->searchForNeighbors ((*indices_)[i], search_parameter_, n_indices, n_sqr_distances);
90 if (getLocalRF ((*indices_)[i], rf) == std::numeric_limits<float>::max ())
91 {
92 output.is_dense = false;
93 }
94
95 for (int d = 0; d < 3; ++d)
96 {
97 output_rf.x_axis[d] = rf.row (0)[d];
98 output_rf.y_axis[d] = rf.row (1)[d];
99 output_rf.z_axis[d] = rf.row (2)[d];
100 }
101 }
102
103}
104
105#define PCL_INSTANTIATE_SHOTLocalReferenceFrameEstimationOMP(T,OutT) template class PCL_EXPORTS pcl::SHOTLocalReferenceFrameEstimationOMP<T,OutT>;
106
107#endif // PCL_FEATURES_IMPL_SHOT_LRF_H_
void computeFeature(PointCloudOut &output) override
Feature estimation method.
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133