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;
110 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
121 template <
typename Po
intT>
125 class SupervoxelHelper;
126 friend class SupervoxelHelper;
135 xyz_ (0.0f, 0.0f, 0.0f),
136 rgb_ (0.0f, 0.0f, 0.0f),
137 normal_ (0.0f, 0.0f, 0.0f, 0.0f),
146 getPoint (
PointT &point_arg)
const;
152 getNormal (
Normal &normal_arg)
const;
163 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
180 typedef boost::adjacency_list<boost::setS, boost::setS, boost::undirectedS, uint32_t, float>
VoxelAdjacencyList;
181 typedef VoxelAdjacencyList::vertex_descriptor
VoxelID;
182 typedef VoxelAdjacencyList::edge_descriptor
EdgeID;
192 SupervoxelClustering (
float voxel_resolution,
float seed_resolution,
bool use_single_camera_transform =
true);
202 setVoxelResolution (
float resolution);
206 getVoxelResolution ()
const;
210 setSeedResolution (
float seed_resolution);
214 getSeedResolution ()
const;
218 setColorImportance (
float val);
222 setSpatialImportance (
float val);
226 setNormalImportance (
float val);
263 getColoredCloud ()
const;
267 getVoxelCentroidCloud ()
const;
274 getLabeledCloud ()
const;
284 getColoredVoxelCloud ()
const;
291 getLabeledVoxelCloud ()
const;
297 getSupervoxelAdjacencyList (VoxelAdjacencyList &adjacency_list_arg)
const;
303 getSupervoxelAdjacency (std::multimap<uint32_t, uint32_t> &label_adjacency)
const;
315 getMaxLabel ()
const;
323 initializeLabelColors ();
329 prepareForSegmentation ();
335 selectInitialSupervoxelSeeds (std::vector<
PointT, Eigen::aligned_allocator<PointT> > &seed_points);
341 createSupervoxelHelpers (std::vector<
PointT, Eigen::aligned_allocator<PointT> > &seed_points);
345 expandSupervoxels (
int depth);
353 reseedSupervoxels ();
363 float seed_resolution_;
371 transformFunction (
PointT &p);
386 float color_importance_;
388 float spatial_importance_;
390 float normal_importance_;
393 std::vector<uint32_t> label_colors_;
399 class SupervoxelHelper
408 addLeaf (LeafContainerT* leaf_arg);
411 removeLeaf (LeafContainerT* leaf_arg);
439 {
return centroid_.normal_; }
443 {
return centroid_.rgb_; }
447 {
return centroid_.xyz_;}
450 getXYZ (
float &x,
float &y,
float &z)
const
451 { x=centroid_.xyz_[0]; y=centroid_.xyz_[1]; z=centroid_.xyz_[2]; }
454 getRGB (uint32_t &rgba)
const
456 rgba =
static_cast<uint32_t
>(centroid_.rgb_[0]) << 16 |
457 static_cast<uint32_t>(centroid_.rgb_[1]) << 8 |
458 static_cast<uint32_t
>(centroid_.rgb_[2]);
464 normal_arg.normal_x = centroid_.normal_[0];
465 normal_arg.normal_y = centroid_.normal_[1];
466 normal_arg.normal_z = centroid_.normal_[2];
467 normal_arg.
curvature = centroid_.curvature_;
471 getNeighborLabels (std::set<uint32_t> &neighbor_labels)
const;
475 {
return centroid_; }
479 size ()
const {
return leaves_.size (); }
482 std::set<LeafContainerT*> leaves_;
485 SupervoxelClustering* parent_;
490 typedef boost::ptr_list<SupervoxelHelper> HelperListT;
491 HelperListT supervoxel_helpers_;
496 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
504 #ifdef PCL_NO_PRECOMPILE
505 #include <pcl/segmentation/impl/supervoxel_clustering.hpp>
boost::shared_ptr< KdTree< PointT > > Ptr
pcl::PointCloud< Normal > NormalCloudT
VoxelAdjacencyList::edge_descriptor EdgeID
Octree adjacency leaf container class- stores set of pointers to neighbors, number of points added...
SupervoxelHelper * owner_
std::vector< LeafContainerT * > LeafVectorT
pcl::octree::OctreePointCloudAdjacency< PointT, LeafContainerT > OctreeAdjacencyT
pcl::PointCloud< PointT >::Ptr voxels_
A Pointcloud of the voxels in the supervoxel.
boost::shared_ptr< const Supervoxel< PointT > > ConstPtr
pcl::octree::OctreePointCloudAdjacencyContainer< PointT, VoxelData > LeafContainerT
pcl::PointCloud< PointT > PointCloudT
pcl::Normal normal_
The normal calculated for the voxels contained in the supervoxel.
boost::shared_ptr< std::vector< int > > IndicesPtr
pcl::octree::OctreePointCloudSearch< PointT > OctreeSearchT
A point structure representing normal coordinates and the surface curvature estimate.
VoxelAdjacencyList::vertex_descriptor VoxelID
pcl::PointCloud< Normal >::Ptr normals_
A Pointcloud of the normals for the points in the supervoxel.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
boost::adjacency_list< boost::setS, boost::setS, boost::undirectedS, uint32_t, float > VoxelAdjacencyList
Octree pointcloud voxel class used for adjacency calculation
A point structure representing Euclidean xyz coordinates, and the RGBA color.
void getCentroidPointNormal(PointNormal &normal_arg)
Gets the point normal for the supervoxel.
Octree pointcloud search class
VoxelData is a structure used for storing data within a pcl::octree::OctreePointCloudAdjacencyContain...
boost::shared_ptr< Supervoxel< PointT > > Ptr
Implements a supervoxel algorithm based on voxel structure, normals, and rgb values.
boost::shared_ptr< OctreeAdjacencyT > Ptr
A point structure representing Euclidean xyz coordinates, and the RGB color.
void getCentroidPoint(PointXYZRGBA ¢roid_arg)
Gets the centroid of the supervoxel.
boost::shared_ptr< PointCloud< PointT > > Ptr
PointCloud represents the base class in PCL for storing collections of 3D points. ...
A point structure representing Euclidean xyz coordinates, together with normal coordinates and the su...
pcl::search::KdTree< PointT > KdTreeT
Supervoxel container class - stores a cluster extracted using supervoxel clustering.
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
pcl::PointXYZRGBA centroid_
The centroid of the supervoxel - average voxel.