40 #include <pcl/pcl_base.h> 42 #include <pcl/point_cloud.h> 43 #include <pcl/segmentation/supervoxel_clustering.h> 45 #define PCL_INSTANTIATE_LCCPSegmentation(T) template class PCL_EXPORTS pcl::LCCPSegmentation<T>; 57 template <
typename Po
intT>
64 float normal_difference;
73 bool used_for_cutting;
76 normal_difference (0), is_convex (
false), is_valid (
false), used_for_cutting (
false)
84 using SupervoxelAdjacencyList = boost::adjacency_list<boost::setS, boost::setS, boost::undirectedS, std::uint32_t, EdgeProperties>;
85 using VertexIterator =
typename boost::graph_traits<SupervoxelAdjacencyList>::vertex_iterator;
86 using AdjacencyIterator =
typename boost::graph_traits<SupervoxelAdjacencyList>::adjacency_iterator;
88 using VertexID =
typename boost::graph_traits<SupervoxelAdjacencyList>::vertex_descriptor;
89 using EdgeIterator =
typename boost::graph_traits<SupervoxelAdjacencyList>::edge_iterator;
90 using OutEdgeIterator =
typename boost::graph_traits<SupervoxelAdjacencyList>::out_edge_iterator;
91 using EdgeID =
typename boost::graph_traits<SupervoxelAdjacencyList>::edge_descriptor;
108 const std::multimap<std::uint32_t, std::uint32_t> &label_adjacency_arg)
136 PCL_WARN (
"[pcl::LCCPSegmentation::getSegmentMap] WARNING: Call function segment first. Nothing has been done. \n");
137 segment_supervoxel_map_arg = std::map<std::uint32_t, std::set<std::uint32_t> > ();
152 PCL_WARN (
"[pcl::LCCPSegmentation::getSegmentMap] WARNING: Call function segment first. Nothing has been done. \n");
153 supervoxel_segment_map_arg = std::map<std::uint32_t, std::uint32_t> ();
170 PCL_WARN (
"[pcl::LCCPSegmentation::getSegmentAdjacencyMap] WARNING: Call function segment first. Nothing has been done. \n");
171 segment_adjacency_map_arg = std::map<std::uint32_t, std::set<std::uint32_t> > ();
194 PCL_WARN (
"[pcl::LCCPSegmentation::getSVAdjacencyList] WARNING: Call function segment first. Nothing has been done. \n");
216 float smoothness_threshold_arg = 0.1)
263 const std::multimap<std::uint32_t, std::uint32_t> &label_adjacency_arg);
276 const unsigned int group_label);
296 float &normal_angle);
353 #ifdef PCL_NO_PRECOMPILE 354 #include <pcl/segmentation/impl/lccp_segmentation.hpp> typename boost::graph_traits< SupervoxelAdjacencyList >::out_edge_iterator OutEdgeIterator
bool use_smoothness_check_
Determines if the smoothness check is used during segmentation.
A simple segmentation algorithm partitioning a supervoxel graph into groups of locally convex connect...
void doGrouping()
Perform depth search on the graph and recursively group all supervoxels with convex connections...
void computeSegmentAdjacency()
Compute the adjacency of the segments.
void relabelCloud(pcl::PointCloud< pcl::PointXYZL > &labeled_cloud_arg)
Relabels cloud with supervoxel labels with the computed segment labels.
bool use_sanity_check_
Determines if we use the sanity check which tries to find and invalidate singular connected patches...
void setKFactor(const std::uint32_t k_factor_arg)
Set the value used for k convexity.
void getSVAdjacencyList(SupervoxelAdjacencyList &adjacency_list_arg) const
Get the supervoxel adjacency graph with classified edges (boost::adjacency_list). ...
std::map< std::uint32_t, typename pcl::Supervoxel< PointT >::Ptr > sv_label_to_supervoxel_map_
map from the supervoxel labels to the supervoxel objects
std::map< std::uint32_t, bool > processed_
Stores which supervoxel labels were already visited during recursive grouping.
float voxel_resolution_
Voxel resolution used to build the supervoxels (used only for smoothness check)
void prepareSegmentation(const std::map< std::uint32_t, typename pcl::Supervoxel< PointT >::Ptr > &supervoxel_clusters_arg, const std::multimap< std::uint32_t, std::uint32_t > &label_adjacency_arg)
Is called within setInputSupervoxels mainly to reserve required memory.
std::uint32_t k_factor_
Factor used for k-convexity.
typename boost::graph_traits< SupervoxelAdjacencyList >::edge_iterator EdgeIterator
void getSegmentAdjacencyMap(std::map< std::uint32_t, std::set< std::uint32_t > > &segment_adjacency_map_arg)
Get map <SegmentID, std::set<Neighboring SegmentIDs> >
bool connIsConvex(const std::uint32_t source_label_arg, const std::uint32_t target_label_arg, float &normal_angle)
Returns true if the connection between source and target is convex.
typename boost::graph_traits< SupervoxelAdjacencyList >::edge_descriptor EdgeID
boost::adjacency_list< boost::setS, boost::setS, boost::undirectedS, std::uint32_t, EdgeProperties > SupervoxelAdjacencyList
virtual ~LCCPSegmentation()
float seed_resolution_
Seed resolution of the supervoxels (used only for smoothness check)
Defines all the PCL implemented PointT point type structures.
float getConcavityToleranceThreshold() const
Get normal threshold.
void setSanityCheck(const bool use_sanity_criterion_arg)
Determines if we want to use the sanity criterion to invalidate singular connected patches...
void setSmoothnessCheck(bool use_smoothness_check_arg, float voxel_res_arg, float seed_res_arg, float smoothness_threshold_arg=0.1)
Determines if a smoothness check is done during segmentation, trying to invalidate edges of non-smoot...
std::map< std::uint32_t, std::uint32_t > sv_label_to_seg_label_map_
Storing relation between original SuperVoxel Labels and new segmantion labels.
float smoothness_threshold_
Two supervoxels are unsmooth if their plane-to-plane distance DIST > (expected_distance + smoothness_...
std::uint32_t min_segment_size_
Minimum segment size.
void reset()
Reset internal memory.
typename boost::graph_traits< SupervoxelAdjacencyList >::vertex_descriptor VertexID
void setMinSegmentSize(const std::uint32_t min_segment_size_arg)
Set the value min_segment_size_ used in mergeSmallSegments.
typename boost::graph_traits< SupervoxelAdjacencyList >::vertex_iterator VertexIterator
bool supervoxels_set_
Marks if supervoxels have been set by calling setInputSupervoxels.
shared_ptr< Supervoxel< PointT > > Ptr
void mergeSmallSegments()
Segments smaller than min_segment_size_ are merged to the label of largest neighbor.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
void getSegmentToSupervoxelMap(std::map< std::uint32_t, std::set< std::uint32_t > > &segment_supervoxel_map_arg) const
Get map<SegmentID, std::set<SuperVoxel IDs> >
void setConcavityToleranceThreshold(float concavity_tolerance_threshold_arg)
Set normal threshold.
void segment()
Merge supervoxels using local convexity.
std::map< std::uint32_t, std::set< std::uint32_t > > seg_label_to_neighbor_set_map_
map < SegmentID, std::set< Neighboring segment labels> >
std::map< std::uint32_t, std::set< std::uint32_t > > seg_label_to_sv_list_map_
map Segment Label to a set of Supervoxel Labels
void recursiveSegmentGrowing(const VertexID &queryPointID, const unsigned int group_label)
Assigns neighbors of the query point to the same group as the query point.
float concavity_tolerance_threshold_
*** Parameters *** ///
void calculateConvexConnections(SupervoxelAdjacencyList &adjacency_list_arg)
Calculates convexity of edges and saves this to the adjacency graph.
void applyKconvexity(const unsigned int k_arg)
Connections are only convex if this is true for at least k_arg common neighbors of the two patches...
void setInputSupervoxels(const std::map< std::uint32_t, typename pcl::Supervoxel< PointT >::Ptr > &supervoxel_clusters_arg, const std::multimap< std::uint32_t, std::uint32_t > &label_adjacency_arg)
Set the supervoxel clusters as well as the adjacency graph for the segmentation.Those parameters are ...
bool grouping_data_valid_
Marks if valid grouping data (sv_adjacency_list_, sv_label_to_seg_label_map_, processed_) is availabl...
void getSupervoxelToSegmentMap(std::map< std::uint32_t, std::uint32_t > &supervoxel_segment_map_arg) const
Get map<Supervoxel_ID, Segment_ID>
SupervoxelAdjacencyList sv_adjacency_list_
Adjacency graph with the supervoxel labels as nodes and edges between adjacent supervoxels.
typename boost::graph_traits< SupervoxelAdjacencyList >::adjacency_iterator AdjacencyIterator