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>
48 #include <pcl/octree/octree_search.h>
49 #include <pcl/octree/octree_pointcloud_adjacency.h>
50 #include <pcl/search/search.h>
51 #include <pcl/segmentation/boost.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
122 template <
typename Po
intT>
126 class SupervoxelHelper;
127 friend class SupervoxelHelper;
136 xyz_ (0.0f, 0.0f, 0.0f),
137 rgb_ (0.0f, 0.0f, 0.0f),
138 normal_ (0.0f, 0.0f, 0.0f, 0.0f),
147 getPoint (
PointT &point_arg)
const;
153 getNormal (
Normal &normal_arg)
const;
164 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
181 typedef boost::adjacency_list<boost::setS, boost::setS, boost::undirectedS, uint32_t, float>
VoxelAdjacencyList;
182 typedef VoxelAdjacencyList::vertex_descriptor
VoxelID;
183 typedef VoxelAdjacencyList::edge_descriptor
EdgeID;
193 PCL_DEPRECATED (
"SupervoxelClustering 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. To force use/disuse of the transform, use the setUseSingleCameraTransform(bool) function.")
204 setVoxelResolution (
float resolution);
208 getVoxelResolution () const;
212 setSeedResolution (
float seed_resolution);
216 getSeedResolution () const;
220 setColorImportance (
float val);
224 setSpatialImportance (
float val);
228 setNormalImportance (
float val);
241 setUseSingleCameraTransform (
bool val);
260 setNormalCloud (typename
NormalCloudT::ConstPtr normal_cloud);
267 refineSupervoxels (
int num_itr,
std::map<uint32_t,typename
Supervoxel<
PointT>::Ptr > &supervoxel_clusters);
277 PCL_DEPRECATED ("
SupervoxelClustering::getColoredCloud is deprecated. Use the getLabeledCloud function instead. examples/segmentation/example_supervoxels.cpp shows how to use this to display and
save with colorized labels.")
279 getColoredCloud ()
const
286 getVoxelCentroidCloud ()
const;
293 getLabeledCloud ()
const;
302 PCL_DEPRECATED (
"SupervoxelClustering::getColoredVoxelCloud is deprecated. Use the getLabeledVoxelCloud function instead. examples/segmentation/example_supervoxels.cpp shows how to use this to display and save with colorized labels.")
304 getColoredVoxelCloud ()
const
314 getLabeledVoxelCloud ()
const;
320 getSupervoxelAdjacencyList (VoxelAdjacencyList &adjacency_list_arg)
const;
326 getSupervoxelAdjacency (std::multimap<uint32_t, uint32_t> &label_adjacency)
const;
338 getMaxLabel ()
const;
345 prepareForSegmentation ();
351 selectInitialSupervoxelSeeds (std::vector<int> &seed_indices);
357 createSupervoxelHelpers (std::vector<int> &seed_indices);
361 expandSupervoxels (
int depth);
369 reseedSupervoxels ();
379 float seed_resolution_;
383 voxelDataDistance (
const VoxelData &v1,
const VoxelData &v2)
const;
387 transformFunction (
PointT &p);
393 typename OctreeAdjacencyT::Ptr adjacency_octree_;
399 typename NormalCloudT::ConstPtr input_normals_;
402 float color_importance_;
404 float spatial_importance_;
406 float normal_importance_;
412 bool use_single_camera_transform_;
414 bool use_default_transform_behaviour_;
420 class SupervoxelHelper
432 return leaf_data_left.
idx_ < leaf_data_right.
idx_;
435 typedef std::set<LeafContainerT*, typename SupervoxelHelper::compareLeaves> LeafSetT;
436 typedef typename LeafSetT::iterator iterator;
437 typedef typename LeafSetT::const_iterator const_iterator;
445 addLeaf (LeafContainerT* leaf_arg);
448 removeLeaf (LeafContainerT* leaf_arg);
476 {
return centroid_.normal_; }
480 {
return centroid_.rgb_; }
484 {
return centroid_.xyz_;}
487 getXYZ (
float &x,
float &y,
float &z)
const
488 { x=centroid_.xyz_[0]; y=centroid_.xyz_[1]; z=centroid_.xyz_[2]; }
491 getRGB (uint32_t &rgba)
const
493 rgba =
static_cast<uint32_t
>(centroid_.rgb_[0]) << 16 |
494 static_cast<uint32_t
>(centroid_.rgb_[1]) << 8 |
495 static_cast<uint32_t
>(centroid_.rgb_[2]);
501 normal_arg.normal_x = centroid_.normal_[0];
502 normal_arg.normal_y = centroid_.normal_[1];
503 normal_arg.normal_z = centroid_.normal_[2];
504 normal_arg.
curvature = centroid_.curvature_;
508 getNeighborLabels (std::set<uint32_t> &neighbor_labels)
const;
512 {
return centroid_; }
515 size ()
const {
return leaves_.size (); }
521 SupervoxelClustering* parent_;
524 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
530 typedef boost::ptr_list<SupervoxelHelper> HelperListT;
531 HelperListT supervoxel_helpers_;
536 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
542 #ifdef PCL_NO_PRECOMPILE
543 #include <pcl/segmentation/impl/supervoxel_clustering.hpp>