40 #ifndef PCL_FEATURES_IMPL_FPFH_OMP_H_
41 #define PCL_FEATURES_IMPL_FPFH_OMP_H_
46 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT>
void
49 std::vector<int> spfh_indices_vec;
50 std::vector<int> spfh_hist_lookup (surface_->points.size ());
54 if (surface_ != input_ ||
55 indices_->size () != surface_->points.size ())
57 std::vector<int> nn_indices (k_);
58 std::vector<float> nn_dists (k_);
60 std::set<int> spfh_indices_set;
61 for (
size_t idx = 0; idx < indices_->size (); ++idx)
63 int p_idx = (*indices_)[idx];
64 if (this->searchForNeighbors (p_idx, search_parameter_, nn_indices, nn_dists) == 0)
67 spfh_indices_set.insert (nn_indices.begin (), nn_indices.end ());
69 spfh_indices_vec.resize (spfh_indices_set.size ());
70 std::copy (spfh_indices_set.begin (), spfh_indices_set.end (), spfh_indices_vec.begin ());
75 spfh_indices_vec.resize (indices_->size ());
76 for (
int idx = 0; idx < static_cast<int> (indices_->size ()); ++idx)
77 spfh_indices_vec[idx] = idx;
81 size_t data_size = spfh_indices_vec.size ();
82 hist_f1_.setZero (data_size, nr_bins_f1_);
83 hist_f2_.setZero (data_size, nr_bins_f2_);
84 hist_f3_.setZero (data_size, nr_bins_f3_);
88 #pragma omp parallel for schedule (dynamic, threads_)
89 for (
int i = 0; i < static_cast<int> (spfh_indices_vec.size ()); ++i)
92 int p_idx = spfh_indices_vec[i];
95 std::vector<int> nn_indices (k_);
96 std::vector<float> nn_dists (k_);
97 if (this->searchForNeighbors (*surface_, p_idx, search_parameter_, nn_indices, nn_dists) == 0)
101 this->computePointSPFHSignature (*surface_, *normals_, p_idx, i, nn_indices, hist_f1_, hist_f2_, hist_f3_);
104 spfh_hist_lookup[p_idx] = i;
108 int nr_bins = nr_bins_f1_ + nr_bins_f2_ + nr_bins_f3_;
111 #pragma omp parallel for schedule (dynamic, threads_)
112 for (
int idx = 0; idx < static_cast<int> (indices_->size ()); ++idx)
115 std::vector<int> nn_indices (k_);
116 std::vector<float> nn_dists (k_);
117 if (!
isFinite ((*input_)[(*indices_)[idx]]) ||
118 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
120 for (
int d = 0; d < nr_bins; ++d)
121 output.points[idx].histogram[d] = std::numeric_limits<float>::quiet_NaN ();
123 output.is_dense =
false;
130 for (
size_t i = 0; i < nn_indices.size (); ++i)
131 nn_indices[i] = spfh_hist_lookup[nn_indices[i]];
134 Eigen::VectorXf fpfh_histogram = Eigen::VectorXf::Zero (nr_bins);
135 weightPointSPFHSignature (hist_f1_, hist_f2_, hist_f3_, nn_indices, nn_dists, fpfh_histogram);
138 for (
int d = 0; d < nr_bins; ++d)
139 output.points[idx].histogram[d] = fpfh_histogram[d];
144 #define PCL_INSTANTIATE_FPFHEstimationOMP(T,NT,OutT) template class PCL_EXPORTS pcl::FPFHEstimationOMP<T,NT,OutT>;
146 #endif // PCL_FEATURES_IMPL_FPFH_OMP_H_