44 #include <pcl/point_cloud.h>
45 #include <pcl/common/point_tests.h>
46 #include <pcl/search/search.h>
47 #include <pcl/common/eigen.h>
64 template<
typename Po
intT>
75 using Ptr = shared_ptr<pcl::search::OrganizedNeighbor<PointT> >;
76 using ConstPtr = shared_ptr<const pcl::search::OrganizedNeighbor<PointT> >;
90 OrganizedNeighbor (
bool sorted_results =
false,
float eps = 1e-4f,
unsigned pyramid_level = 5)
114 float min_f = 0.043744332f *
static_cast<float>(
input_->width);
116 return (determinant3x3Matrix<Eigen::Matrix3f> (
KR_ / std::sqrt (
KR_KRT_.coeff (8))) >= (min_f * min_f));
148 for (std::size_t idx=0; idx<
input_->size(); ++idx)
170 std::vector<float> &k_sqr_distances,
171 unsigned int max_nn = 0)
const override;
190 std::vector<float> &k_sqr_distances)
const override;
229 float dist_x = point.x - query.x;
230 float dist_y = point.y - query.y;
231 float dist_z = point.z - query.z;
232 float squared_distance = dist_x * dist_x + dist_y * dist_y + dist_z * dist_z;
233 const auto queue_size = queue.size ();
234 const auto insert_into_queue = [&]{ queue.emplace (
235 std::upper_bound (queue.begin(), queue.end(), squared_distance,
236 [](
float dist,
const Entry& ent){ return dist<ent.distance; }),
237 index, squared_distance); };
240 insert_into_queue ();
241 return (queue_size + 1) == k;
243 if (queue.back ().distance > squared_distance)
246 insert_into_queue ();
254 clipRange (
int& begin,
int &end,
int min,
int max)
const
256 begin = std::max (std::min (begin, max), min);
257 end = std::min (std::max (end, min), max);
270 unsigned& maxX,
unsigned& maxY)
const;
277 Eigen::Matrix<float, 3, 3, Eigen::RowMajor>
KR_;
280 Eigen::Matrix<float, 3, 3, Eigen::RowMajor>
KR_KRT_;
296 #ifdef PCL_NO_PRECOMPILE
297 #include <pcl/search/impl/organized.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
OrganizedNeighbor is a class for optimized nearest neighbor search in organized projectable point clo...
bool estimateProjectionMatrix()
estimated the projection matrix from the input cloud.
typename PointCloud::ConstPtr PointCloudConstPtr
int radiusSearch(const PointT &p_q, double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const override
Search for all neighbors of query point that are within a given radius.
int nearestKSearch(const PointT &p_q, int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const override
Search for the k-nearest neighbors for a given query point.
bool isValid() const
Test whether this search-object is valid (input is organized AND from projective device) User should ...
Eigen::Matrix< float, 3, 3, Eigen::RowMajor > KR_
inveser of the left 3x3 projection matrix which is K * R (with K being the camera matrix and R the ro...
shared_ptr< const pcl::search::OrganizedNeighbor< PointT > > ConstPtr
void computeCameraMatrix(Eigen::Matrix3f &camera_matrix) const
Compute the camera matrix.
bool testPoint(const PointT &query, unsigned k, std::vector< Entry > &queue, index_t index) const
test if point given by index is among the k NN in results to the query point.
std::vector< unsigned char > mask_
mask, indicating whether the point was in the indices list or not, and whether it is finite.
void clipRange(int &begin, int &end, int min, int max) const
Eigen::Matrix< float, 3, 4, Eigen::RowMajor > projection_matrix_
the projection matrix.
typename PointCloud::Ptr PointCloudPtr
const unsigned pyramid_level_
using only a subsample of points to calculate the projection matrix.
Eigen::Matrix< float, 3, 3, Eigen::RowMajor > KR_KRT_
inveser of the left 3x3 projection matrix which is K * R (with K being the camera matrix and R the ro...
shared_ptr< pcl::search::OrganizedNeighbor< PointT > > Ptr
OrganizedNeighbor(bool sorted_results=false, float eps=1e-4f, unsigned pyramid_level=5)
Constructor.
bool setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr()) override
Provide a pointer to the input data set, if user has focal length he must set it before calling this.
bool projectPoint(const PointT &p, pcl::PointXY &q) const
projects a point into the image
void getProjectedRadiusSearchBox(const PointT &point, float squared_radius, unsigned &minX, unsigned &minY, unsigned &maxX, unsigned &maxY) const
Obtain a search box in 2D from a sphere with a radius in 3D.
~OrganizedNeighbor() override=default
Empty deconstructor.
const float eps_
epsilon value for the MSE of the projection matrix estimation
PointCloudConstPtr input_
pcl::IndicesConstPtr IndicesConstPtr
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Defines functions, macros and traits for allocating and using memory.
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...
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.
Defines all the PCL and non-PCL macros used.
A 2D point structure representing Euclidean xy coordinates.
A point structure representing Euclidean xyz coordinates, and the RGB color.
bool operator<(const Entry &other) const
Entry(index_t idx, float dist)