示例#1
0
template <typename PointT> void
pcl::LCCPSegmentation<PointT>::segment (std::map<uint32_t, typename pcl::Supervoxel<PointT>::Ptr>& supervoxel_clusters_arg,
                                        std::multimap<boost::uint32_t, boost::uint32_t>& label_adjacency_arg)
{
  // Initialization
  prepareSegmentation (supervoxel_clusters_arg, label_adjacency_arg);  // after this, sv_adjacency_list_ can be used to access adjacency list

  // Calculate for every Edge if the connection is convex or invalid
  // This effectively performs the segmentation.
  calculateConvexConnections (sv_adjacency_list_);

  // Correct edge relations using extended convexity definition if k>0
  applyKconvexity (k_factor_);

  // Perform depth search on the graph and recursively group all supervoxels with convex connections
  //The vertices in the supervoxel adjacency list are the supervoxel centroids
  std::pair< VertexIterator, VertexIterator> vertex_iterator_range;
  vertex_iterator_range = boost::vertices (sv_adjacency_list_);

  // Note: *sv_itr is of type " boost::graph_traits<VoxelAdjacencyList>::vertex_descriptor " which it nothing but a typedef of size_t..
  unsigned int segment_label = 1;  // This starts at 1, because 0 is reserved for errors
  for (VertexIterator sv_itr = vertex_iterator_range.first; sv_itr != vertex_iterator_range.second; ++sv_itr)  // For all SuperVoxels
  {
    const VertexID sv_vertex_id = *sv_itr;
    const uint32_t sv_label = sv_adjacency_list_[sv_vertex_id];
    if (!processed_[sv_label])
    {
      // Add neighbors (and their neighbors etc.) to group if similarity constraint is met
      recursiveGrouping (sv_vertex_id, segment_label);
      ++segment_label;  // After recursive grouping ended (no more neighbors to consider) -> go to next group
    }
  }
  grouping_data_valid_ = true;
}
示例#2
0
template <typename PointT> void
pcl::LCCPSegmentation<PointT>::segment ()
{
  if (supervoxels_set_)
  {
    // Calculate for every Edge if the connection is convex or invalid
    // This effectively performs the segmentation.
    calculateConvexConnections (sv_adjacency_list_);

    // Correct edge relations using extended convexity definition if k>0
    applyKconvexity (k_factor_);

    // group supervoxels
    doGrouping ();
    
    grouping_data_valid_ = true;
    
    // merge small segments
    mergeSmallSegments ();
  }
  else
    PCL_WARN ("[pcl::LCCPSegmentation::segment] WARNING: Call function setInputSupervoxels first. Nothing has been done. \n");
}