Point Cloud Library (PCL)
1.9.1
|
38 #ifndef PCL_VOXEL_GRID_COVARIANCE_H_
39 #define PCL_VOXEL_GRID_COVARIANCE_H_
41 #include <pcl/filters/boost.h>
42 #include <pcl/filters/voxel_grid.h>
45 #include <pcl/kdtree/kdtree_flann.h>
56 template<
typename Po
intT>
87 typedef boost::shared_ptr< VoxelGrid<PointT> >
Ptr;
88 typedef boost::shared_ptr< const VoxelGrid<PointT> >
ConstPtr;
224 if(min_points_per_voxel > 2)
230 PCL_WARN (
"%s: Covariance calculation requires at least 3 points, setting Min Point per Voxel to 3 ", this->
getClassName ().c_str ());
305 typename std::map<size_t, Leaf>::iterator leaf_iter =
leaves_.find (index);
306 if (leaf_iter !=
leaves_.end ())
331 typename std::map<size_t, Leaf>::iterator leaf_iter =
leaves_.find (idx);
332 if (leaf_iter !=
leaves_.end ())
358 typename std::map<size_t, Leaf>::iterator leaf_iter =
leaves_.find (idx);
359 if (leaf_iter !=
leaves_.end ())
382 inline const std::map<size_t, Leaf>&
415 std::vector<LeafConstPtr> &k_leaves, std::vector<float> &k_sqr_distances)
422 PCL_WARN (
"%s: Not Searchable", this->
getClassName ().c_str ());
427 std::vector<int> k_indices;
428 k =
kdtree_.nearestKSearch (point, k, k_indices, k_sqr_distances);
431 k_leaves.reserve (k);
432 for (std::vector<int>::iterator iter = k_indices.begin (); iter != k_indices.end (); iter++)
450 std::vector<LeafConstPtr> &k_leaves, std::vector<float> &k_sqr_distances)
452 if (index >=
static_cast<int> (cloud.
points.size ()) || index < 0)
469 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
476 PCL_WARN (
"%s: Not Searchable", this->
getClassName ().c_str ());
481 std::vector<int> k_indices;
482 int k =
kdtree_.radiusSearch (point, radius, k_indices, k_sqr_distances, max_nn);
485 k_leaves.reserve (k);
486 for (std::vector<int>::iterator iter = k_indices.begin (); iter != k_indices.end (); iter++)
505 std::vector<LeafConstPtr> &k_leaves, std::vector<float> &k_sqr_distances,
506 unsigned int max_nn = 0)
508 if (index >=
static_cast<int> (cloud.
points.size ()) || index < 0)
510 return (
radiusSearch (cloud.
points[index], radius, k_leaves, k_sqr_distances, max_nn));
543 #ifdef PCL_NO_PRECOMPILE
544 #include <pcl/filters/impl/voxel_grid_covariance.hpp>
547 #endif //#ifndef PCL_VOXEL_GRID_COVARIANCE_H_
VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
This file defines compatibility wrappers for low level I/O functions.
VoxelGridCovariance()
Constructor.
boost::shared_ptr< PointCloud< PointT > > Ptr
const std::map< size_t, Leaf > & getLeaves()
Get the leaf structure map.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
double getCovEigValueInflationRatio()
Get the minimum allowable ratio between eigenvalues to prevent singular covariance matrices.
PointCloud::Ptr PointCloudPtr
const typedef Leaf * LeafConstPtr
Const pointer to VoxelGridCovariance leaf structure.
Eigen::Matrix3d icov_
Inverse of voxel covariance matrix.
bool downsample_all_data_
Set to true if all fields need to be downsampled, or false if just XYZ.
void applyFilter(PointCloud &output)
Filter cloud and initializes voxel structure.
PointCloud represents the base class in PCL for storing collections of 3D points.
Eigen::Array4f inverse_leaf_size_
Internal leaf sizes stored as 1/leaf_size_ for efficiency reasons.
int getNeighborhoodAtPoint(const PointT &reference_point, std::vector< LeafConstPtr > &neighbors)
Get the voxels surrounding point p, not including the voxel containing point p.
A point structure representing Euclidean xyz coordinates, and the RGB color.
LeafConstPtr getLeaf(PointT &p)
Get the voxel containing point p.
LeafConstPtr getLeaf(int index)
Get the voxel containing point p.
bool save_leaf_layout_
Set to true if leaf layout information needs to be saved in leaf_layout_.
PointCloudPtr voxel_centroids_
Point cloud containing centroids of voxels containing atleast minimum number of points.
Eigen::Vector3d getMean() const
Get the voxel centroid.
void filter(bool searchable=false)
Initializes voxel structure.
std::vector< int > voxel_centroids_leaf_indices_
Indices of leaf structurs associated with each point in voxel_centroids_ (used for searching).
KdTreeFLANN< PointT > kdtree_
KdTree generated using voxel_centroids_ (used for searching).
Eigen::VectorXf centroid
Nd voxel centroid.
int radiusSearch(const PointCloud &cloud, int index, double radius, std::vector< LeafConstPtr > &k_leaves, std::vector< float > &k_sqr_distances, unsigned int max_nn=0)
Search for all the nearest occupied voxels of the query point in a given radius.
PointCloud::ConstPtr PointCloudConstPtr
PointCloudPtr getCentroids()
Get a pointcloud containing the voxel centroids.
void getDisplayCloud(pcl::PointCloud< PointXYZ > &cell_cloud)
Get a cloud to visualize each voxels normal distribution.
Eigen::Matrix3d getEvecs() const
Get the eigen vectors of the voxel covariance.
KdTreeFLANN is a generic type of 3D spatial locator using kD-tree structures.
A searchable voxel strucure containing the mean and covariance of the data.
Eigen::Vector3d evals_
Eigen values of voxel covariance matrix.
Eigen::Vector4i min_b_
The minimum and maximum bin coordinates, the number of divisions, and the division multiplier.
Eigen::Vector3d getEvals() const
Get the eigen values of the voxel covariance.
PointCloud::Ptr PointCloudPtr
Eigen::Matrix3d evecs_
Eigen vectors of voxel covariance matrix.
Eigen::Vector3d mean_
3D voxel centroid
bool searchable_
Flag to determine if voxel structure is searchable.
Eigen::Matrix3d getCov() const
Get the voxel covariance.
boost::shared_ptr< const VoxelGrid< PointT > > ConstPtr
double min_covar_eigvalue_mult_
Minimum allowable ratio between eigenvalues to prevent singular covariance matrices.
Filter< PointT >::PointCloud PointCloud
boost::shared_ptr< VoxelGrid< PointT > > Ptr
LeafConstPtr getLeaf(Eigen::Vector3f &p)
Get the voxel containing point p.
int radiusSearch(const PointT &point, double radius, std::vector< LeafConstPtr > &k_leaves, std::vector< float > &k_sqr_distances, unsigned int max_nn=0)
Search for all the nearest occupied voxels of the query point in a given radius.
Leaf * LeafPtr
Pointer to VoxelGridCovariance leaf structure.
pcl::traits::fieldList< PointT >::type FieldList
Eigen::Vector4i divb_mul_
void setMinPointPerVoxel(int min_points_per_voxel)
Set the minimum number of points required for a cell to be used (must be 3 or greater for covariance ...
int getMinPointPerVoxel()
Get the minimum number of points required for a cell to be used.
void filter(PointCloud &output, bool searchable=false)
Filter cloud and initializes voxel structure.
std::string filter_name_
The filter name.
Eigen::Matrix3d getInverseCov() const
Get the inverse of the voxel covariance.
int getPointCount() const
Get the number of points contained by this voxel.
boost::shared_ptr< const PointCloud< PointTarget > > ConstPtr
Eigen::Matrix3d cov_
Voxel covariance matrix.
const std::string & getClassName() const
Get a string representation of the name of this class.
int nr_points
Number of points contained by voxel.
Eigen::Vector4f leaf_size_
The size of a leaf.
Simple structure to hold a centroid, covarince and the number of points in a leaf.
std::map< size_t, Leaf > leaves_
Voxel structure containing all leaf nodes (includes voxels with less than a sufficient number of poin...
int min_points_per_voxel_
Minimum points contained with in a voxel to allow it to be usable.
void setCovEigValueInflationRatio(double min_covar_eigvalue_mult)
Set the minimum allowable ratio between eigenvalues to prevent singular covariance matrices.
int nearestKSearch(const PointT &point, int k, std::vector< LeafConstPtr > &k_leaves, std::vector< float > &k_sqr_distances)
Search for the k-nearest occupied voxels for the given query point.
int nearestKSearch(const PointCloud &cloud, int index, int k, std::vector< LeafConstPtr > &k_leaves, std::vector< float > &k_sqr_distances)
Search for the k-nearest occupied voxels for the given query point.