1#ifndef POINTCLOUD_DEPTH_NEIGHBOR_SEARCH_HPP
2#define POINTCLOUD_DEPTH_NEIGHBOR_SEARCH_HPP
12 template<
typename Po
intT>
24 template<
typename Po
intT>
38 template<
typename Po
intT>
44 if (input_->height == 1)
46 PCL_ERROR (
"[pcl::%s::radiusSearch] Input dataset is not organized!\n", getName ().
c_str ());
65 int idx = y * input_->width + x;
66 const PointT& point = (*input_)[idx];
89 template<
typename Po
intT>
96 double x1, x2,
y1,
y2;
118 minX_arg = (
int)std::floor((
double)input_->width / 2 + (x1 / focalLength_));
119 maxX_arg = (
int)std::ceil((
double)input_->width / 2 + (x2 / focalLength_));
121 minY_arg = (
int)std::floor((
double)input_->height / 2 + (
y1 / focalLength_));
122 maxY_arg = (
int)std::ceil((
double)input_->height / 2 + (
y2 / focalLength_));
135 template<
typename Po
intT>
147 template<
typename Po
intT>
159 template<
typename Po
intT>
172 if (input_->height == 1)
174 PCL_ERROR (
"[pcl::%s::nearestKSearch] Input dataset is not organized!\n", getName ().
c_str ());
204 x =
x_pos + (*radiusSearchLookup_Iterator).x_diff_;
205 y =
y_pos + (*radiusSearchLookup_Iterator).y_diff_;
209 if ((x >= 0) && (y >= 0) && (x < (
int)input_->width) && (y < (
int)input_->height))
211 idx = y * (
int)input_->width + x;
212 const PointT& point = (*input_)[idx];
214 if ((point.x == point.x) &&
215 (point.y == point.y) &&
216 (point.z == point.z))
275 x =
x_pos + (*radiusSearchLookup_Iterator).x_diff_;
276 y =
y_pos + (*radiusSearchLookup_Iterator).y_diff_;
279 if ((x >= 0) && (y >= 0) && (x < (
int)input_->width) && (y < (
int)input_->height))
281 idx = y * (
int)input_->width + x;
282 const PointT& point = (*input_)[idx];
284 if ((point.x == point.x) &&
285 (point.y == point.y) && (point.z == point.z))
335 template<
typename Po
intT>
341 std::size_t count = 0;
342 for (
int y = 0; y < (
int)input_->height; y++)
343 for (
int x = 0; x < (
int)input_->width; x++)
345 std::size_t i = y * input_->width + x;
346 if (((*input_)[i].x == (*input_)[i].x) &&
347 ((*input_)[i].y == (*input_)[i].y) && ((*input_)[i].z == (*input_)[i].z))
349 const PointT& point = (*input_)[i];
350 if ((
double)(x - input_->width / 2) * (
double)(y - input_->height / 2) * point.z != 0)
353 focalLength_ += point.x / ((
double)(x - (
int)input_->width / 2) * point.z);
354 focalLength_ += point.y / ((
double)(y - (
int)input_->height / 2) * point.z);
360 focalLength_ /= (
double)count;
364 template<
typename Po
intT>
368 if ( (this->radiusLookupTableWidth_!=(
int)width) || (this->radiusLookupTableHeight_!=(
int)height) )
371 this->radiusLookupTableWidth_ = (
int)width;
372 this->radiusLookupTableHeight_= (
int)height;
374 radiusSearchLookup_.clear ();
375 radiusSearchLookup_.resize ((2*width+1) * (2*height+1));
378 for (
int x = -(
int)width; x < (
int)width+1; x++)
379 for (
int y = -(
int)height; y <(
int)height+1; y++)
381 radiusSearchLookup_[
c++].defineShiftedSearchPoint(x, y);
384 std::sort (radiusSearchLookup_.begin (), radiusSearchLookup_.end ());
390 template<
typename Po
intT>
403#define PCL_INSTANTIATE_OrganizedNeighborSearch(T) template class pcl::OrganizedNeighborSearch<T>;
Iterator class for point clouds with or without given indices.
ConstCloudIterator(const PointCloud< PointT > &cloud)
std::size_t size() const
Size of the range the iterator is going through.
nearestNeighborCandidate entry for the nearest neighbor candidate queue
void getProjectedRadiusSearchBox(const PointT &point_arg, double squared_radius_arg, int &minX_arg, int &minY_arg, int &maxX_arg, int &maxY_arg) const
int radiusSearch(const PointCloudConstPtr &cloud_arg, int index_arg, double radius_arg, std::vector< int > &k_indices_arg, std::vector< float > &k_sqr_distances_arg, int max_nn_arg=INT_MAX)
Search for all neighbors of query point that are within a given radius.
int nearestKSearch(const PointCloudConstPtr &cloud_arg, int index_arg, int k_arg, std::vector< int > &k_indices_arg, std::vector< float > &k_sqr_distances_arg)
Search for k-nearest neighbors at the query point.
void estimateFocalLengthFromInputCloud()
Estimate focal length parameter that was used during point cloud generation.
typename PointCloud::ConstPtr PointCloudConstPtr
void generateRadiusLookupTable(unsigned int width, unsigned int height)
Generate radius lookup table.
const PointT & getPointByIndex(const unsigned int index_arg) const
Get point at index from input pointcloud dataset.
A point structure representing Euclidean xyz coordinates, and the RGB color.