38#ifndef PCL_SEGMENTATION_IMPL_LCCP_SEGMENTATION_HPP_
39#define PCL_SEGMENTATION_IMPL_LCCP_SEGMENTATION_HPP_
41#include <pcl/segmentation/lccp_segmentation.h>
53template <
typename Po
intT>
55 concavity_tolerance_threshold_ (10),
56 grouping_data_valid_ (
false),
57 supervoxels_set_ (
false),
58 use_smoothness_check_ (
false),
59 smoothness_threshold_ (0.1),
60 use_sanity_check_ (
false),
62 voxel_resolution_ (0),
68template <
typename Po
intT>
73template <
typename Po
intT>
void
76 sv_adjacency_list_.clear ();
78 sv_label_to_supervoxel_map_.clear ();
79 sv_label_to_seg_label_map_.clear ();
80 seg_label_to_sv_list_map_.clear ();
81 seg_label_to_neighbor_set_map_.clear ();
82 grouping_data_valid_ =
false;
83 supervoxels_set_ =
false;
86template <
typename Po
intT>
void
93 calculateConvexConnections (sv_adjacency_list_);
96 applyKconvexity (k_factor_);
101 grouping_data_valid_ =
true;
104 mergeSmallSegments ();
107 PCL_WARN (
"[pcl::LCCPSegmentation::segment] WARNING: Call function setInputSupervoxels first. Nothing has been done. \n");
111template <
typename Po
intT>
void
114 if (grouping_data_valid_)
119 voxel.label = sv_label_to_seg_label_map_[
voxel.label];
124 PCL_WARN (
"[pcl::LCCPSegmentation::relabelCloud] WARNING: Call function segment first. Nothing has been done. \n");
136template <
typename Po
intT>
void
139 seg_label_to_neighbor_set_map_.clear ();
167template <
typename Po
intT>
void
170 if (min_segment_size_ == 0)
173 computeSegmentAdjacency ();
239 computeSegmentAdjacency ();
243template <
typename Po
intT>
void
275 boost::add_edge (u, v, sv_adjacency_list_);
280 seg_label_to_sv_list_map_.clear ();
286 sv_label_to_seg_label_map_[
sv_label] = 0;
293template <
typename Po
intT>
void
297 seg_label_to_sv_list_map_.clear ();
303 sv_label_to_seg_label_map_[
sv_label] = 0;
324template <
typename Po
intT>
void
354template <
typename Po
intT>
void
366 bool is_convex = sv_adjacency_list_[*
edge_itr].is_convex;
406 (sv_adjacency_list_)[*
edge_itr].is_valid =
false;
411template <
typename Po
intT>
void
423 float normal_difference;
431template <
typename Po
intT>
bool
446 if (concavity_tolerance_threshold_ < 0)
451 bool is_convex =
true;
465 if (use_smoothness_check_)
471 const float dist_smoothing = smoothness_threshold_ * voxel_resolution_;
500 is_convex &= (
normal_angle < concavity_tolerance_threshold_);
Iterator class for point clouds with or without given indices.
std::size_t size() const
Size of the range the iterator is going through.
virtual ~LCCPSegmentation()
typename boost::graph_traits< SupervoxelAdjacencyList >::vertex_iterator VertexIterator
typename boost::graph_traits< SupervoxelAdjacencyList >::edge_iterator EdgeIterator
boost::adjacency_list< boost::setS, boost::setS, boost::undirectedS, std::uint32_t, EdgeProperties > SupervoxelAdjacencyList
void recursiveSegmentGrowing(const VertexID &queryPointID, const unsigned int group_label)
Assigns neighbors of the query point to the same group as the query point.
void calculateConvexConnections(SupervoxelAdjacencyList &adjacency_list_arg)
Calculates convexity of edges and saves this to the adjacency graph.
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.
void mergeSmallSegments()
Segments smaller than min_segment_size_ are merged to the label of largest neighbor.
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.
void segment()
Merge supervoxels using local convexity.
typename boost::graph_traits< SupervoxelAdjacencyList >::out_edge_iterator OutEdgeIterator
typename boost::graph_traits< SupervoxelAdjacencyList >::adjacency_iterator AdjacencyIterator
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.
void doGrouping()
Perform depth search on the graph and recursively group all supervoxels with convex connections.
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.
typename boost::graph_traits< SupervoxelAdjacencyList >::edge_descriptor EdgeID
typename boost::graph_traits< SupervoxelAdjacencyList >::vertex_descriptor VertexID
void reset()
Reset internal memory.
Define standard C methods and C++ classes that are common to all methods.
double getAngle3D(const Eigen::Vector4f &v1, const Eigen::Vector4f &v2, const bool in_degree=false)
Compute the smallest angle between two 3D vectors in radians (default) or degree.