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_search.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
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
428 bool operator() (LeafContainerT*
const &left, LeafContainerT*
const &right)
const
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>
A point structure representing normal coordinates and the surface curvature estimate.
pcl::octree::OctreePointCloudAdjacency< PointT, LeafContainerT > OctreeAdjacencyT
boost::shared_ptr< PointCloud< PointT > > Ptr
pcl::PointCloud< PointT >::Ptr voxels_
A Pointcloud of the voxels in the supervoxel.
Octree adjacency leaf container class- stores a list of pointers to neighbors, number of points added...
pcl::PointXYZRGBA centroid_
The centroid of the supervoxel - average voxel.
Octree pointcloud voxel class which maintains adjacency information for its voxels.
This file defines compatibility wrappers for low level I/O functions.
void getCentroidPointNormal(PointNormal &normal_arg)
Gets the point normal for the supervoxel.
pcl::Normal normal_
The normal calculated for the voxels contained in the supervoxel.
VoxelAdjacencyList::vertex_descriptor VoxelID
pcl::PointCloud< PointT > PointCloudT
boost::shared_ptr< std::vector< int > > IndicesPtr
A point structure representing Euclidean xyz coordinates, and the RGBA color.
boost::shared_ptr< const Supervoxel< PointT > > ConstPtr
Supervoxel container class - stores a cluster extracted using supervoxel clustering.
boost::shared_ptr< KdTree< PointT, Tree > > Ptr
pcl::octree::OctreePointCloudSearch< PointT > OctreeSearchT
VoxelData is a structure used for storing data within a pcl::octree::OctreePointCloudAdjacencyContain...
std::vector< LeafContainerT * > LeafVectorT
SupervoxelHelper * owner_
pcl::search::KdTree< PointT > KdTreeT
void getCentroidPoint(PointXYZRGBA ¢roid_arg)
Gets the centroid of the supervoxel.
Implements a supervoxel algorithm based on voxel structure, normals, and rgb values.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
pcl::PointCloud< Normal > NormalCloudT
Comparator for LeafContainerT pointers - used for sorting set of leaves.
A point structure representing Euclidean xyz coordinates, together with normal coordinates and the su...
DataT & getData()
Returns a reference to the data member to access it without copying.
Octree pointcloud search class
VoxelAdjacencyList::edge_descriptor EdgeID
pcl::octree::OctreePointCloudAdjacencyContainer< PointT, VoxelData > LeafContainerT
pcl::PointCloud< Normal >::Ptr normals_
A Pointcloud of the normals for the points in the supervoxel.
PCL_EXPORTS int save(const std::string &file_name, const pcl::PCLPointCloud2 &blob, unsigned precision=5)
Save point cloud data to a binary file when available else to ASCII.
A point structure representing Euclidean xyz coordinates, and the RGB color.
boost::shared_ptr< Supervoxel< PointT > > Ptr
boost::adjacency_list< boost::setS, boost::setS, boost::undirectedS, uint32_t, float > VoxelAdjacencyList