43 #include <boost/version.hpp>
45 #include <pcl/features/normal_3d.h>
47 #include <pcl/pcl_base.h>
49 #include <pcl/point_cloud.h>
51 #include <pcl/octree/octree_search.h>
52 #include <pcl/octree/octree_pointcloud_adjacency.h>
53 #include <pcl/search/search.h>
54 #include <pcl/segmentation/boost.h>
66 template <
typename Po
intT>
75 using Ptr = shared_ptr<Supervoxel<PointT> >;
76 using ConstPtr = shared_ptr<const Supervoxel<PointT> >;
97 normal_arg.normal_x =
normal_.normal_x;
98 normal_arg.normal_y =
normal_.normal_y;
99 normal_arg.normal_z =
normal_.normal_z;
125 template <
typename Po
intT>
129 class SupervoxelHelper;
130 friend class SupervoxelHelper;
139 xyz_ (0.0f, 0.0f, 0.0f),
140 rgb_ (0.0f, 0.0f, 0.0f),
141 normal_ (0.0f, 0.0f, 0.0f, 0.0f),
152 getPoint (
PointT &point_arg)
const;
158 getNormal (
Normal &normal_arg)
const;
186 using VoxelAdjacencyList = boost::adjacency_list<boost::setS, boost::setS, boost::undirectedS, std::uint32_t, float>;
187 using VoxelID = VoxelAdjacencyList::vertex_descriptor;
188 using EdgeID = VoxelAdjacencyList::edge_descriptor;
206 setVoxelResolution (
float resolution);
210 getVoxelResolution ()
const;
214 setSeedResolution (
float seed_resolution);
218 getSeedResolution ()
const;
222 setColorImportance (
float val);
226 setSpatialImportance (
float val);
230 setNormalImportance (
float val);
243 setUseSingleCameraTransform (
bool val);
269 refineSupervoxels (
int num_itr, std::map<std::uint32_t,
typename Supervoxel<PointT>::Ptr > &supervoxel_clusters);
274 getVoxelCentroidCloud ()
const;
281 getLabeledCloud ()
const;
288 getLabeledVoxelCloud ()
const;
300 getSupervoxelAdjacency (std::multimap<std::uint32_t, std::uint32_t> &label_adjacency)
const;
312 getMaxLabel ()
const;
319 prepareForSegmentation ();
325 selectInitialSupervoxelSeeds (
Indices &seed_indices);
331 createSupervoxelHelpers (
Indices &seed_indices);
335 expandSupervoxels (
int depth);
343 reseedSupervoxels ();
353 float seed_resolution_;
361 transformFunction (
PointT &p);
376 float color_importance_;
378 float spatial_importance_;
380 float normal_importance_;
386 bool use_single_camera_transform_;
388 bool use_default_transform_behaviour_;
394 class SupervoxelHelper
406 return leaf_data_left.
idx_ < leaf_data_right.
idx_;
409 using LeafSetT = std::set<LeafContainerT*, typename SupervoxelHelper::compareLeaves>;
410 using iterator =
typename LeafSetT::iterator;
411 using const_iterator =
typename LeafSetT::const_iterator;
419 addLeaf (LeafContainerT* leaf_arg);
422 removeLeaf (LeafContainerT* leaf_arg);
450 {
return centroid_.normal_; }
454 {
return centroid_.rgb_; }
458 {
return centroid_.xyz_;}
461 getXYZ (
float &x,
float &y,
float &z)
const
462 { x=centroid_.xyz_[0]; y=centroid_.xyz_[1]; z=centroid_.xyz_[2]; }
465 getRGB (std::uint32_t &rgba)
const
467 rgba =
static_cast<std::uint32_t
>(centroid_.rgb_[0]) << 16 |
468 static_cast<std::uint32_t
>(centroid_.rgb_[1]) << 8 |
469 static_cast<std::uint32_t
>(centroid_.rgb_[2]);
475 normal_arg.normal_x = centroid_.normal_[0];
476 normal_arg.normal_y = centroid_.normal_[1];
477 normal_arg.normal_z = centroid_.normal_[2];
478 normal_arg.
curvature = centroid_.curvature_;
482 getNeighborLabels (std::set<std::uint32_t> &neighbor_labels)
const;
486 {
return centroid_; }
489 size ()
const {
return leaves_.size (); }
493 std::uint32_t label_;
495 SupervoxelClustering* parent_;
502 #if BOOST_VERSION >= 107000
508 using HelperListT = boost::ptr_list<SupervoxelHelper>;
509 HelperListT supervoxel_helpers_;
519 #ifdef PCL_NO_PRECOMPILE
520 #include <pcl/segmentation/impl/supervoxel_clustering.hpp>