41 #ifndef PCL_SEGMENTATION_SUPERVOXEL_CLUSTERING_H_
42 #define PCL_SEGMENTATION_SUPERVOXEL_CLUSTERING_H_
44 #include <pcl/features/normal_3d.h>
45 #include <pcl/pcl_base.h>
46 #include <pcl/point_cloud.h>
47 #include <pcl/point_types.h>
48 #include <pcl/octree/octree.h>
49 #include <pcl/octree/octree_pointcloud_adjacency.h>
50 #include <pcl/search/search.h>
51 #include <pcl/segmentation/boost.h>
56 #include <pcl/common/time.h>
63 template <
typename Po
intT>
72 typedef boost::shared_ptr<Supervoxel<PointT> >
Ptr;
73 typedef boost::shared_ptr<const Supervoxel<PointT> >
ConstPtr;
94 normal_arg.normal_x =
normal_.normal_x;
95 normal_arg.normal_y =
normal_.normal_y;
96 normal_arg.normal_z =
normal_.normal_z;
118 template <
typename Po
intT>
122 class SupervoxelHelper;
123 friend class SupervoxelHelper;
124 #define MAX_LABEL 16384
133 xyz_ (0.0f, 0.0f, 0.0f),
134 rgb_ (0.0f, 0.0f, 0.0f),
135 normal_ (0.0f, 0.0f, 0.0f, 0.0f),
144 getPoint (
PointT &point_arg)
const;
150 getNormal (
Normal &normal_arg)
const;
175 typedef boost::adjacency_list<boost::setS, boost::setS, boost::undirectedS, uint32_t, float>
VoxelAdjacencyList;
176 typedef VoxelAdjacencyList::vertex_descriptor
VoxelID;
177 typedef VoxelAdjacencyList::edge_descriptor
EdgeID;
187 SupervoxelClustering (
float voxel_resolution,
float seed_resolution,
bool use_single_camera_transform =
true);
197 setVoxelResolution (
float resolution);
201 getVoxelResolution ()
const;
205 setSeedResolution (
float seed_resolution);
209 getSeedResolution ()
const;
213 setColorImportance (
float val);
217 setSpatialImportance (
float val);
221 setNormalImportance (
float val);
251 getColoredCloud ()
const;
255 getVoxelCentroidCloud ()
const;
262 getLabeledCloud ()
const;
271 getColoredVoxelCloud ()
const;
278 getLabeledVoxelCloud ()
const;
290 getSupervoxelAdjacency (std::multimap<uint32_t, uint32_t> &label_adjacency)
const;
305 prepareForSegmentation ();
311 selectInitialSupervoxelSeeds (std::vector<
PointT, Eigen::aligned_allocator<PointT> > &seed_points);
317 createSupervoxelHelpers (std::vector<
PointT, Eigen::aligned_allocator<PointT> > &seed_points);
321 expandSupervoxels (
int depth);
329 reseedSupervoxels ();
339 float seed_resolution_;
347 transformFunction (
PointT &p);
359 float color_importance_;
361 float spatial_importance_;
363 float normal_importance_;
366 std::vector<uint32_t> label_colors_;
372 class SupervoxelHelper
381 addLeaf (LeafContainerT* leaf_arg);
384 removeLeaf (LeafContainerT* leaf_arg);
412 {
return centroid_.normal_; }
416 {
return centroid_.rgb_; }
420 {
return centroid_.xyz_;}
423 getXYZ (
float &x,
float &y,
float &z)
const
424 { x=centroid_.xyz_[0]; y=centroid_.xyz_[1]; z=centroid_.xyz_[2]; }
427 getRGB (uint32_t &rgba)
const
429 rgba =
static_cast<uint32_t
>(centroid_.rgb_[0]) << 16 |
430 static_cast<uint32_t>(centroid_.rgb_[1]) << 8 |
431 static_cast<uint32_t
>(centroid_.rgb_[2]);
437 normal_arg.normal_x = centroid_.normal_[0];
438 normal_arg.normal_y = centroid_.normal_[1];
439 normal_arg.normal_z = centroid_.normal_[2];
440 normal_arg.
curvature = centroid_.curvature_;
444 getNeighborLabels (std::set<uint32_t> &neighbor_labels)
const;
448 {
return centroid_; }
452 size ()
const {
return leaves_.size (); }
455 std::set<LeafContainerT*> leaves_;
458 SupervoxelClustering* parent_;
463 typedef boost::ptr_list<SupervoxelHelper> HelperListT;
464 HelperListT supervoxel_helpers_;
469 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
477 #ifdef PCL_NO_PRECOMPILE
478 #include <pcl/segmentation/impl/supervoxel_clustering.hpp>
A point structure representing normal coordinates and the surface curvature estimate.
pcl::octree::OctreePointCloudAdjacency< PointT, LeafContainerT > OctreeAdjacencyT
pcl::PointCloud< PointT >::Ptr voxels_
A Pointcloud of the voxels in the supervoxel.
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Octree adjacency leaf container class- stores set of pointers to neighbors, number of points added...
pcl::PointXYZRGBA centroid_
The centroid of the supervoxel - average voxel.
boost::shared_ptr< PointCloud< PointT > > Ptr
Octree pointcloud voxel class used for adjacency calculation
void getCentroidPointNormal(PointNormal &normal_arg)
Gets the point normal for the supervoxel.
pcl::Normal normal_
The normal calculated for the voxels contained in the supervoxel.
VoxelAdjacencyList::vertex_descriptor VoxelID
pcl::PointCloud< PointT > PointCloudT
boost::shared_ptr< std::vector< int > > IndicesPtr
A point structure representing Euclidean xyz coordinates, and the RGBA color.
boost::shared_ptr< const Supervoxel< PointT > > ConstPtr
Supervoxel container class - stores a cluster extracted using supervoxel clustering.
boost::shared_ptr< KdTree< PointT > > Ptr
pcl::octree::OctreePointCloudSearch< PointT > OctreeSearchT
VoxelData is a structure used for storing data within a pcl::octree::OctreePointCloudAdjacencyContain...
std::vector< LeafContainerT * > LeafVectorT
SupervoxelHelper * owner_
pcl::search::KdTree< PointT > KdTreeT
void getCentroidPoint(PointXYZRGBA ¢roid_arg)
Gets the centroid of the supervoxel.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
Implements a supervoxel algorithm based on voxel structure, normals, and rgb values.
pcl::PointCloud< Normal > NormalCloudT
A point structure representing Euclidean xyz coordinates, together with normal coordinates and the su...
boost::shared_ptr< OctreeAdjacencyT > Ptr
Octree pointcloud search class
VoxelAdjacencyList::edge_descriptor EdgeID
pcl::octree::OctreePointCloudAdjacencyContainer< PointT, VoxelData > LeafContainerT
pcl::PointCloud< Normal >::Ptr normals_
A Pointcloud of the normals for the points in the supervoxel.
A point structure representing Euclidean xyz coordinates, and the RGB color.
boost::shared_ptr< Supervoxel< PointT > > Ptr
boost::adjacency_list< boost::setS, boost::setS, boost::undirectedS, uint32_t, float > VoxelAdjacencyList