44 #include <pcl/common/io.h>
45 #include <pcl/common/point_tests.h>
46 #include <pcl/filters/local_maximum.h>
47 #include <pcl/filters/project_inliers.h>
48 #include <pcl/ModelCoefficients.h>
49 #include <pcl/search/organized.h>
50 #include <pcl/search/kdtree.h>
53 template <
typename Po
intT>
void
59 PCL_WARN (
"[pcl::%s::applyFilter] No input dataset given!\n", getClassName ().c_str ());
68 applyFilterIndices (indices);
69 pcl::copyPointCloud<PointT> (*input_, indices, output);
73 template <
typename Po
intT>
void
80 coefficients->values.resize (4);
81 coefficients->values[0] = coefficients->values[1] = 0;
82 coefficients->values[2] = 1.0;
83 coefficients->values[3] = 0;
90 proj.
filter (*cloud_projected);
95 if (input_->isOrganized ())
100 searcher_->setInputCloud (cloud_projected);
103 indices.resize (indices_->size ());
104 removed_indices_->resize (indices_->size ());
105 int oii = 0, rii = 0;
107 std::vector<bool> point_is_max (indices_->size (),
false);
108 std::vector<bool> point_is_visited (indices_->size (),
false);
113 for (
const auto& iii : (*indices_))
122 if (point_is_visited[iii] && !point_is_max[iii])
128 point_is_max[iii] =
true;
129 point_is_visited[iii] =
true;
133 std::vector<float> radius_dists;
134 PointT p = (*cloud_projected)[iii];
135 if (searcher_->radiusSearch (p, radius_, radius_indices, radius_dists) == 0)
137 PCL_WARN (
"[pcl::%s::applyFilter] Searching for neighbors within radius %f failed.\n", getClassName ().c_str (), radius_);
142 if (radius_indices.size () == 1)
144 point_is_max[iii] =
false;
148 float query_z = (*input_)[iii].z;
149 for (std::size_t k = 1; k < radius_indices.size (); ++k)
151 if ((*input_)[radius_indices[k]].z > query_z)
154 point_is_max[iii] =
false;
161 if (point_is_max[iii])
163 for (std::size_t k = 1; k < radius_indices.size (); ++k)
165 point_is_visited[radius_indices[k]] =
true;
171 if ((!negative_ && point_is_max[iii]) || (negative_ && !point_is_max[iii]))
173 if (extract_removed_indices_)
175 (*removed_indices_)[rii++] = iii;
182 indices[oii++] = iii;
186 indices.resize (oii);
187 removed_indices_->resize (rii);
190 #define PCL_INSTANTIATE_LocalMaximum(T) template class PCL_EXPORTS pcl::LocalMaximum<T>;