40 #ifndef PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
41 #define PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
43 #include <pcl/common/point_tests.h>
44 #include <pcl/filters/radius_outlier_removal.h>
45 #include <pcl/search/auto.h>
48 template <
typename Po
intT>
void
51 if (search_radius_ == 0.0)
53 PCL_ERROR (
"[pcl::%s::applyFilter] No radius defined!\n", getClassName ().c_str ());
55 removed_indices_->clear ();
64 else if (!searcher_->setInputCloud (input_))
66 PCL_ERROR (
"[pcl::%s::applyFilter] Error when initializing search method!\n", getClassName ().c_str ());
68 removed_indices_->clear ();
73 const int mean_k = min_pts_radius_ + 1;
74 const double nn_dists_max = search_radius_ * search_radius_;
78 std::vector<float> nn_dists(mean_k);
82 std::vector<std::uint8_t> to_keep(indices_->size(), 1);
83 indices.resize (indices_->size ());
84 removed_indices_->resize (indices_->size ());
90 #pragma omp parallel for \
91 schedule(dynamic,64) \
92 firstprivate(nn_indices, nn_dists) \
94 num_threads(num_threads_)
95 for (ptrdiff_t i = 0; i < static_cast<ptrdiff_t>(indices_->size()); i++)
97 const auto& index = (*indices_)[i];
99 const int k = searcher_->nearestKSearch (index, mean_k, nn_indices, nn_dists);
108 if ((!negative_ && nn_dists_max < nn_dists[k-1]) || (negative_ && nn_dists_max >= nn_dists[k - 1]))
128 #pragma omp parallel for \
129 schedule(dynamic, 64) \
130 firstprivate(nn_indices, nn_dists) \
132 num_threads(num_threads_)
133 for (ptrdiff_t i = 0; i < static_cast<ptrdiff_t>(indices_->size()); i++)
135 const auto& index = (*indices_)[i];
145 const int k = searcher_->radiusSearch (index, search_radius_, nn_indices, nn_dists, min_pts_radius_ + 1);
149 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
157 for (
index_t i=0; i < static_cast<index_t>(to_keep.size()); i++)
161 if (extract_removed_indices_)
162 (*removed_indices_)[rii++] = (*indices_)[i];
167 indices[oii++] = (*indices_)[i];
171 indices.resize (oii);
172 removed_indices_->resize (rii);
175 #define PCL_INSTANTIATE_RadiusOutlierRemoval(T) template class PCL_EXPORTS pcl::RadiusOutlierRemoval<T>;
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
@ radius_search
The search method will mainly be used for radiusSearch.
@ many_knn_search
The search method will mainly be used for nearestKSearch where k is larger than 1.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
IndicesAllocator<> Indices
Type used for indices in PCL.
constexpr bool isXYZFinite(const PointT &) noexcept