42 #ifndef PCL_FILTERS_IMPL_LOCAL_MAXIMUM_H_ 43 #define PCL_FILTERS_IMPL_LOCAL_MAXIMUM_H_ 45 #include <pcl/common/io.h> 46 #include <pcl/filters/local_maximum.h> 47 #include <pcl/filters/project_inliers.h> 48 #include <pcl/ModelCoefficients.h> 51 template <
typename Po
intT>
void 57 PCL_WARN (
"[pcl::%s::applyFilter] No input dataset given!\n", getClassName ().c_str ());
63 std::vector<int> indices;
66 applyFilterIndices (indices);
67 pcl::copyPointCloud<PointT> (*input_, indices, output);
71 template <
typename Po
intT>
void 78 coefficients->values.resize (4);
79 coefficients->values[0] = coefficients->values[1] = 0;
80 coefficients->values[2] = 1.0;
81 coefficients->values[3] = 0;
88 proj.
filter (*cloud_projected);
93 if (input_->isOrganized ())
98 searcher_->setInputCloud (cloud_projected);
101 indices.resize (indices_->size ());
102 removed_indices_->resize (indices_->size ());
103 int oii = 0, rii = 0;
105 std::vector<bool> point_is_max (indices_->size (),
false);
106 std::vector<bool> point_is_visited (indices_->size (),
false);
111 for (
int iii = 0; iii < static_cast<int> (indices_->size ()); ++iii)
113 if (!
isFinite (input_->points[(*indices_)[iii]]))
120 if (point_is_visited[(*indices_)[iii]] && !point_is_max[(*indices_)[iii]])
126 point_is_max[(*indices_)[iii]] =
true;
127 point_is_visited[(*indices_)[iii]] =
true;
130 std::vector<int> radius_indices;
131 std::vector<float> radius_dists;
132 PointT p = cloud_projected->points[(*indices_)[iii]];
133 if (searcher_->radiusSearch (p, radius_, radius_indices, radius_dists) == 0)
135 PCL_WARN (
"[pcl::%s::applyFilter] Searching for neighbors within radius %f failed.\n", getClassName ().c_str (), radius_);
140 if (radius_indices.size () == 1)
142 point_is_max[(*indices_)[iii]] =
false;
146 float query_z = input_->points[(*indices_)[iii]].z;
147 for (
size_t k = 1; k < radius_indices.size (); ++k)
149 if (input_->points[radius_indices[k]].z > query_z)
152 point_is_max[(*indices_)[iii]] =
false;
159 if (point_is_max[(*indices_)[iii]])
161 for (
size_t k = 1; k < radius_indices.size (); ++k)
163 point_is_visited[radius_indices[k]] =
true;
169 if ((!negative_ && point_is_max[(*indices_)[iii]]) || (negative_ && !point_is_max[(*indices_)[iii]]))
171 if (extract_removed_indices_)
173 (*removed_indices_)[rii++] = (*indices_)[iii];
180 indices[oii++] = (*indices_)[iii];
184 indices.resize (oii);
185 removed_indices_->resize (rii);
188 #define PCL_INSTANTIATE_LocalMaximum(T) template class PCL_EXPORTS pcl::LocalMaximum<T>; 190 #endif // PCL_FILTERS_IMPL_LOCAL_MAXIMUM_H_
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
void setModelCoefficients(const ModelCoefficientsConstPtr &model)
Provide a pointer to the model coefficients.
ProjectInliers uses a model and a set of inlier indices from a PointCloud to project them into a sepa...
void filter(PointCloud &output)
Calls the filtering method and returns the filtered dataset in output.
uint32_t height
The point cloud height (if organized as an image-structure).
boost::shared_ptr< PointCloud< PointT > > Ptr
uint32_t width
The point cloud width (if organized as an image-structure).
void applyFilterIndices(std::vector< int > &indices)
Filtered results are indexed by an indices array.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
void applyFilter(PointCloud &output)
Downsample a Point Cloud by eliminating points that are locally maximal in z.
boost::shared_ptr< ::pcl::ModelCoefficients > Ptr
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields)...
OrganizedNeighbor is a class for optimized nearest neigbhor search in organized point clouds...
A point structure representing Euclidean xyz coordinates, and the RGB color.
void setModelType(int model)
The type of model to use (user given parameter).