43 #include <pcl/features/fpfh_omp.h>
45 #include <pcl/common/point_tests.h>
51 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
56 threads_ = omp_get_num_procs();
61 threads_ = nr_threads;
65 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
68 std::vector<int> spfh_indices_vec;
69 std::vector<int> spfh_hist_lookup (surface_->size ());
73 if (surface_ != input_ ||
74 indices_->size () != surface_->size ())
77 std::vector<float> nn_dists (k_);
79 std::set<int> spfh_indices_set;
80 for (std::size_t idx = 0; idx < indices_->size (); ++idx)
82 int p_idx = (*indices_)[idx];
83 if (!isFinite ((*input_)[p_idx]) ||
84 this->searchForNeighbors (p_idx, search_parameter_, nn_indices, nn_dists) == 0)
87 spfh_indices_set.insert (nn_indices.begin (), nn_indices.end ());
89 spfh_indices_vec.resize (spfh_indices_set.size ());
90 std::copy (spfh_indices_set.cbegin (), spfh_indices_set.cend (), spfh_indices_vec.begin ());
95 spfh_indices_vec.resize (indices_->size ());
96 std::iota(spfh_indices_vec.begin (), spfh_indices_vec.end (),
97 static_cast<decltype(spfh_indices_vec)::value_type
>(0));
101 const auto data_size = spfh_indices_vec.size ();
102 hist_f1_.setZero (data_size, nr_bins_f1_);
103 hist_f2_.setZero (data_size, nr_bins_f2_);
104 hist_f3_.setZero (data_size, nr_bins_f3_);
107 std::vector<float> nn_dists (k_);
111 #pragma omp parallel for \
113 shared(spfh_hist_lookup, spfh_indices_vec) \
114 firstprivate(nn_indices, nn_dists) \
115 num_threads(threads_)
116 for (std::ptrdiff_t i = 0; i < static_cast<std::ptrdiff_t> (spfh_indices_vec.size ()); ++i)
119 int p_idx = spfh_indices_vec[i];
122 if (!isFinite ((*surface_)[p_idx]) ||
123 this->searchForNeighbors (*surface_, p_idx, search_parameter_, nn_indices, nn_dists) == 0)
127 this->computePointSPFHSignature (*surface_, *normals_, p_idx, i, nn_indices, hist_f1_, hist_f2_, hist_f3_);
130 spfh_hist_lookup[p_idx] = i;
134 int nr_bins = nr_bins_f1_ + nr_bins_f2_ + nr_bins_f3_;
140 #pragma omp parallel for \
142 shared(nr_bins, output, spfh_hist_lookup) \
143 firstprivate(nn_dists, nn_indices) \
144 num_threads(threads_)
145 for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
148 if (!isFinite ((*input_)[(*indices_)[idx]]) ||
149 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
151 for (
int d = 0; d < nr_bins; ++d)
152 output[idx].histogram[d] = std::numeric_limits<float>::quiet_NaN ();
154 output.is_dense =
false;
161 for (
auto &nn_index : nn_indices)
162 nn_index = spfh_hist_lookup[nn_index];
165 Eigen::VectorXf fpfh_histogram = Eigen::VectorXf::Zero (nr_bins);
166 weightPointSPFHSignature (hist_f1_, hist_f2_, hist_f3_, nn_indices, nn_dists, fpfh_histogram);
169 for (
int d = 0; d < nr_bins; ++d)
170 output[idx].histogram[d] = fpfh_histogram[d];
175 #define PCL_INSTANTIATE_FPFHEstimationOMP(T,NT,OutT) template class PCL_EXPORTS pcl::FPFHEstimationOMP<T,NT,OutT>;
FPFHEstimationOMP estimates the Fast Point Feature Histogram (FPFH) descriptor for a given point clou...
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
IndicesAllocator<> Indices
Type used for indices in PCL.