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;
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);
380 typename PointCloudT::Ptr voxel_centroid_cloud_;
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>