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;
198 PCL_DEPRECATED(1, 12,
"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.")
209 setVoxelResolution (
float resolution);
213 getVoxelResolution ()
const;
217 setSeedResolution (
float seed_resolution);
221 getSeedResolution ()
const;
225 setColorImportance (
float val);
229 setSpatialImportance (
float val);
233 setNormalImportance (
float val);
246 setUseSingleCameraTransform (
bool val);
265 setNormalCloud (
typename NormalCloudT::ConstPtr normal_cloud);
282 PCL_DEPRECATED(1, 12,
"use getLabeledCloud() instead. An example of how to display and save with colorized labels can be found in examples/segmentation/example_supervoxels.cpp")
284 getColoredCloud ()
const 291 getVoxelCentroidCloud ()
const;
298 getLabeledCloud ()
const;
305 getLabeledVoxelCloud ()
const;
311 getSupervoxelAdjacencyList (VoxelAdjacencyList &adjacency_list_arg)
const;
317 getSupervoxelAdjacency (std::multimap<std::uint32_t, std::uint32_t> &label_adjacency)
const;
329 getMaxLabel ()
const;
336 prepareForSegmentation ();
342 selectInitialSupervoxelSeeds (std::vector<int> &seed_indices);
348 createSupervoxelHelpers (std::vector<int> &seed_indices);
352 expandSupervoxels (
int depth);
360 reseedSupervoxels ();
370 float seed_resolution_;
374 voxelDataDistance (
const VoxelData &v1,
const VoxelData &v2)
const;
378 transformFunction (
PointT &p);
384 typename OctreeAdjacencyT::Ptr adjacency_octree_;
390 typename NormalCloudT::ConstPtr input_normals_;
393 float color_importance_;
395 float spatial_importance_;
397 float normal_importance_;
403 bool use_single_camera_transform_;
405 bool use_default_transform_behaviour_;
411 class SupervoxelHelper
423 return leaf_data_left.
idx_ < leaf_data_right.
idx_;
426 using LeafSetT = std::set<LeafContainerT*, typename SupervoxelHelper::compareLeaves>;
427 using iterator =
typename LeafSetT::iterator;
428 using const_iterator =
typename LeafSetT::const_iterator;
436 addLeaf (LeafContainerT* leaf_arg);
439 removeLeaf (LeafContainerT* leaf_arg);
467 {
return centroid_.normal_; }
471 {
return centroid_.rgb_; }
475 {
return centroid_.xyz_;}
478 getXYZ (
float &x,
float &y,
float &z)
const 479 { x=centroid_.xyz_[0]; y=centroid_.xyz_[1]; z=centroid_.xyz_[2]; }
485 static_cast<std::uint32_t>(centroid_.rgb_[1]) << 8 |
492 normal_arg.normal_x = centroid_.normal_[0];
493 normal_arg.normal_y = centroid_.normal_[1];
494 normal_arg.normal_z = centroid_.normal_[2];
495 normal_arg.
curvature = centroid_.curvature_;
499 getNeighborLabels (std::set<std::uint32_t> &neighbor_labels)
const;
503 {
return centroid_; }
506 size ()
const {
return leaves_.size (); }
512 SupervoxelClustering* parent_;
519 #if BOOST_VERSION >= 107000 525 using HelperListT = boost::ptr_list<SupervoxelHelper>;
526 HelperListT supervoxel_helpers_;
536 #ifdef PCL_NO_PRECOMPILE 537 #include <pcl/segmentation/impl/supervoxel_clustering.hpp> boost::adjacency_list< boost::setS, boost::setS, boost::undirectedS, std::uint32_t, float > VoxelAdjacencyList
A point structure representing normal coordinates and the surface curvature estimate.
shared_ptr< KdTree< PointT, Tree > > Ptr
pcl::PointCloud< PointT >::Ptr voxels_
A Pointcloud of the voxels in the supervoxel.
shared_ptr< PointCloud< PointT > > Ptr
Defines functions, macros and traits for allocating and using memory.
Octree adjacency leaf container class- stores a list of pointers to neighbors, number of points added...
VoxelAdjacencyList::vertex_descriptor VoxelID
pcl::PointXYZRGBA centroid_
The centroid of the supervoxel - average voxel.
Octree pointcloud voxel class which maintains adjacency information for its voxels.
void getCentroidPointNormal(PointNormal &normal_arg)
Gets the point normal for the supervoxel.
shared_ptr< Indices > IndicesPtr
pcl::Normal normal_
The normal calculated for the voxels contained in the supervoxel.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
A point structure representing Euclidean xyz coordinates, and the RGBA color.
shared_ptr< const Supervoxel< PointT > > ConstPtr
Supervoxel container class - stores a cluster extracted using supervoxel clustering.
Defines all the PCL implemented PointT point type structures.
std::vector< LeafContainerT * > LeafVectorT
VoxelData is a structure used for storing data within a pcl::octree::OctreePointCloudAdjacencyContain...
SupervoxelHelper * owner_
void getCentroidPoint(PointXYZRGBA ¢roid_arg)
Gets the centroid of the supervoxel.
shared_ptr< Supervoxel< PointT > > Ptr
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.
Comparator for LeafContainerT pointers - used for sorting set of leaves.
A point structure representing Euclidean xyz coordinates, together with normal coordinates and the su...
VoxelAdjacencyList::edge_descriptor EdgeID
DataT & getData()
Returns a reference to the data member to access it without copying.
Octree pointcloud search class
shared_ptr< const PointCloud< PointT > > ConstPtr
pcl::PointCloud< Normal >::Ptr normals_
A Pointcloud of the normals for the points in the supervoxel.
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major...
A point structure representing Euclidean xyz coordinates, and the RGB color.
Define methods for measuring time spent in code blocks.
Defines all the PCL and non-PCL macros used.
pcl::IndicesPtr IndicesPtr