43 #include <boost/version.hpp>
45 #include <pcl/features/normal_3d.h>
46 #include <pcl/pcl_base.h>
48 #include <pcl/point_cloud.h>
50 #include <pcl/octree/octree_search.h>
51 #include <pcl/octree/octree_pointcloud_adjacency.h>
52 #include <pcl/search/search.h>
53 #include <pcl/segmentation/boost.h>
65 template <
typename Po
intT>
96 normal_arg.normal_x =
normal_.normal_x;
97 normal_arg.normal_y =
normal_.normal_y;
98 normal_arg.normal_z =
normal_.normal_z;
124 template <
typename Po
intT>
128 class SupervoxelHelper;
129 friend class SupervoxelHelper;
138 xyz_ (0.0f, 0.0f, 0.0f),
139 rgb_ (0.0f, 0.0f, 0.0f),
140 normal_ (0.0f, 0.0f, 0.0f, 0.0f),
151 getPoint (
PointT &point_arg)
const;
157 getNormal (
Normal &normal_arg)
const;
185 using VoxelAdjacencyList = boost::adjacency_list<boost::setS, boost::setS, boost::undirectedS, std::uint32_t, float>;
186 using VoxelID = VoxelAdjacencyList::vertex_descriptor;
187 using EdgeID = VoxelAdjacencyList::edge_descriptor;
197 PCL_DEPRECATED(
"constructor with flag for using the single camera transform is deprecated. Default behavior is now to use the transform for organized clouds, and not use it for unorganized. Use setUseSingleCameraTransform() to override the defaults.")
208 setVoxelResolution (
float resolution);
212 getVoxelResolution ()
const;
216 setSeedResolution (
float seed_resolution);
220 getSeedResolution ()
const;
224 setColorImportance (
float val);
228 setSpatialImportance (
float val);
232 setNormalImportance (
float val);
245 setUseSingleCameraTransform (
bool val);
264 setNormalCloud (
typename NormalCloudT::ConstPtr normal_cloud);
271 refineSupervoxels (
int num_itr, std::map<std::uint32_t,
typename Supervoxel<PointT>::Ptr > &supervoxel_clusters);
281 PCL_DEPRECATED(
"use getLabeledCloud() instead. An example of how to display and save with colorized labels can be found in examples/segmentation/example_supervoxels.cpp")
283 getColoredCloud ()
const
290 getVoxelCentroidCloud ()
const;
297 getLabeledCloud ()
const;
304 getLabeledVoxelCloud ()
const;
310 getSupervoxelAdjacencyList (VoxelAdjacencyList &adjacency_list_arg)
const;
316 getSupervoxelAdjacency (std::multimap<std::uint32_t, std::uint32_t> &label_adjacency)
const;
328 getMaxLabel ()
const;
335 prepareForSegmentation ();
341 selectInitialSupervoxelSeeds (std::vector<int> &seed_indices);
347 createSupervoxelHelpers (std::vector<int> &seed_indices);
351 expandSupervoxels (
int depth);
359 reseedSupervoxels ();
369 float seed_resolution_;
373 voxelDataDistance (
const VoxelData &v1,
const VoxelData &v2)
const;
377 transformFunction (
PointT &p);
383 typename OctreeAdjacencyT::Ptr adjacency_octree_;
389 typename NormalCloudT::ConstPtr input_normals_;
392 float color_importance_;
394 float spatial_importance_;
396 float normal_importance_;
402 bool use_single_camera_transform_;
404 bool use_default_transform_behaviour_;
410 class SupervoxelHelper
422 return leaf_data_left.
idx_ < leaf_data_right.
idx_;
425 using LeafSetT = std::set<LeafContainerT*, typename SupervoxelHelper::compareLeaves>;
426 using iterator =
typename LeafSetT::iterator;
427 using const_iterator =
typename LeafSetT::const_iterator;
435 addLeaf (LeafContainerT* leaf_arg);
438 removeLeaf (LeafContainerT* leaf_arg);
466 {
return centroid_.normal_; }
470 {
return centroid_.rgb_; }
474 {
return centroid_.xyz_;}
477 getXYZ (
float &x,
float &y,
float &z)
const
478 { x=centroid_.xyz_[0]; y=centroid_.xyz_[1]; z=centroid_.xyz_[2]; }
481 getRGB (std::uint32_t &rgba)
const
483 rgba =
static_cast<std::uint32_t
>(centroid_.rgb_[0]) << 16 |
484 static_cast<std::uint32_t
>(centroid_.rgb_[1]) << 8 |
485 static_cast<std::uint32_t
>(centroid_.rgb_[2]);
491 normal_arg.normal_x = centroid_.normal_[0];
492 normal_arg.normal_y = centroid_.normal_[1];
493 normal_arg.normal_z = centroid_.normal_[2];
494 normal_arg.
curvature = centroid_.curvature_;
498 getNeighborLabels (std::set<std::uint32_t> &neighbor_labels)
const;
502 {
return centroid_; }
505 size ()
const {
return leaves_.size (); }
509 std::uint32_t label_;
511 SupervoxelClustering* parent_;
518 #if BOOST_VERSION >= 107000
524 using HelperListT = boost::ptr_list<SupervoxelHelper>;
525 HelperListT supervoxel_helpers_;
535 #ifdef PCL_NO_PRECOMPILE
536 #include <pcl/segmentation/impl/supervoxel_clustering.hpp>