40 #ifndef PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
41 #define PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
43 #include <pcl/filters/radius_outlier_removal.h>
44 #include <pcl/common/io.h>
47 template <
typename Po
intT>
void
50 std::vector<int> indices;
53 bool temp = extract_removed_indices_;
54 extract_removed_indices_ =
true;
55 applyFilterIndices (indices);
56 extract_removed_indices_ = temp;
59 for (
int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)
60 output.
points[(*removed_indices_)[rii]].x = output.
points[(*removed_indices_)[rii]].y = output.
points[(*removed_indices_)[rii]].z = user_filter_value_;
61 if (!pcl_isfinite (user_filter_value_))
66 applyFilterIndices (indices);
72 template <
typename Po
intT>
void
75 if (search_radius_ == 0.0)
77 PCL_ERROR (
"[pcl::%s::applyFilter] No radius defined!\n", getClassName ().c_str ());
79 removed_indices_->clear ();
86 if (input_->isOrganized ())
91 searcher_->setInputCloud (input_);
94 std::vector<int> nn_indices (indices_->size ());
95 std::vector<float> nn_dists (indices_->size ());
96 indices.resize (indices_->size ());
97 removed_indices_->resize (indices_->size ());
101 if (input_->is_dense)
104 int mean_k = min_pts_radius_ + 1;
105 double nn_dists_max = search_radius_ * search_radius_;
107 for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
110 int k = searcher_->nearestKSearch (*it, mean_k, nn_indices, nn_dists);
114 bool chk_neighbors =
true;
119 chk_neighbors =
false;
120 if (nn_dists_max < nn_dists[k-1])
122 chk_neighbors =
true;
127 chk_neighbors =
true;
128 if (nn_dists_max < nn_dists[k-1])
130 chk_neighbors =
false;
137 chk_neighbors =
true;
139 chk_neighbors =
false;
146 if (extract_removed_indices_)
147 (*removed_indices_)[rii++] = *it;
152 indices[oii++] = *it;
158 for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
162 int k = searcher_->radiusSearch (*it, search_radius_, nn_indices, nn_dists);
166 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
168 if (extract_removed_indices_)
169 (*removed_indices_)[rii++] = *it;
174 indices[oii++] = *it;
179 indices.resize (oii);
180 removed_indices_->resize (rii);
183 #define PCL_INSTANTIATE_RadiusOutlierRemoval(T) template class PCL_EXPORTS pcl::RadiusOutlierRemoval<T>;
185 #endif // PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
PCL_EXPORTS void copyPointCloud(const pcl::PCLPointCloud2 &cloud_in, const std::vector< int > &indices, pcl::PCLPointCloud2 &cloud_out)
Extract the indices of a given point cloud as a new point cloud.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
void applyFilter(PointCloud &output)
Filtered results are stored in a separate point cloud.
OrganizedNeighbor is a class for optimized nearest neigbhor search in organized point clouds...
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields)...
void applyFilterIndices(std::vector< int > &indices)
Filtered results are indexed by an indices array.