41 #include <pcl/pcl_base.h>
43 #include <pcl/point_cloud.h>
46 #include <pcl/segmentation/supervoxel_clustering.h>
47 #include <pcl/segmentation/lccp_segmentation.h>
48 #include <pcl/sample_consensus/sac.h>
50 #include <pcl/sample_consensus/sac_model_plane.h>
51 #include <pcl/segmentation/extract_clusters.h>
53 #define PCL_INSTANTIATE_CPCSegmentation(T) template class PCL_EXPORTS pcl::CPCSegmentation<T>;
66 template <
typename Po
intT>
110 const float cutting_min_score = 0.16,
111 const bool locally_constrained =
true,
112 const bool directed_cutting =
true,
113 const bool clean_cutting =
false)
115 max_cuts_ = max_cuts;
116 min_segment_size_for_cutting_ = cutting_min_segments;
117 min_cut_score_ = cutting_min_score;
118 use_local_constrains_ = locally_constrained;
119 use_directed_weights_ = directed_cutting;
120 use_clean_cutting_ = clean_cutting;
128 ransac_itrs_ = ransac_iterations;
148 float min_cut_score_;
151 bool use_local_constrains_;
154 bool use_directed_weights_;
157 bool use_clean_cutting_;
175 class WeightedRandomSampleConsensus :
public SampleConsensus<WeightSACPointType>
180 using Ptr = shared_ptr<WeightedRandomSampleConsensus>;
181 using ConstPtr = shared_ptr<const WeightedRandomSampleConsensus>;
187 WeightedRandomSampleConsensus (
const SampleConsensusModelPtr &model,
199 WeightedRandomSampleConsensus (
const SampleConsensusModelPtr &model,
202 : SampleConsensus<WeightSACPointType> (model, threshold, random)
211 computeModel (
int debug_verbosity_level = 0)
override;
217 setWeights (
const std::vector<double> &weights,
218 const bool directed_weights =
false)
220 if (weights.size () != full_cloud_pt_indices_->size ())
222 PCL_ERROR (
"[pcl::WeightedRandomSampleConsensus::setWeights] Cannot assign weights. Weight vector needs to have the same length as the input pointcloud\n");
226 model_pt_indices_->clear ();
227 for (std::size_t i = 0; i < weights.size (); ++i)
229 if (weights[i] > std::numeric_limits<double>::epsilon ())
230 model_pt_indices_->push_back (i);
232 use_directed_weights_ = directed_weights;
239 getBestScore ()
const
241 return (best_score_);
251 use_directed_weights_ =
false;
252 model_pt_indices_.reset (
new std::vector<int>);
253 full_cloud_pt_indices_.reset (
new std::vector<int> (* (
sac_model_->getIndices ())));
254 point_cloud_ptr_ =
sac_model_->getInputCloud ();
258 bool use_directed_weights_;
261 std::vector<double> weights_;
279 #ifdef PCL_NO_PRECOMPILE
280 #include <pcl/segmentation/impl/cpc_segmentation.hpp>
281 #elif defined(PCL_ONLY_CORE_POINT_TYPES)
283 #include <pcl/sample_consensus/impl/sac_model_plane.hpp>
284 #include <pcl/segmentation/impl/extract_clusters.hpp>
A segmentation algorithm partitioning a supervoxel graph.
void segment()
Merge supervoxels using cuts through local convexities.
void setCutting(const std::uint32_t max_cuts=20, const std::uint32_t cutting_min_segments=0, const float cutting_min_score=0.16, const bool locally_constrained=true, const bool directed_cutting=true, const bool clean_cutting=false)
Determines if we want to use cutting planes.
void setRANSACIterations(const std::uint32_t ransac_iterations)
Set the number of iterations for the weighted RANSAC step (best cut estimations)
A simple segmentation algorithm partitioning a supervoxel graph into groups of locally convex connect...
bool supervoxels_set_
Marks if supervoxels have been set by calling setInputSupervoxels.
std::map< std::uint32_t, std::uint32_t > sv_label_to_seg_label_map_
Storing relation between original SuperVoxel Labels and new segmantion labels.
typename boost::graph_traits< SupervoxelAdjacencyList >::edge_iterator EdgeIterator
bool grouping_data_valid_
Marks if valid grouping data (sv_adjacency_list_, sv_label_to_seg_label_map_, processed_) is availabl...
std::uint32_t k_factor_
Factor used for k-convexity.
void calculateConvexConnections(SupervoxelAdjacencyList &adjacency_list_arg)
Calculates convexity of edges and saves this to the adjacency graph.
void mergeSmallSegments()
Segments smaller than min_segment_size_ are merged to the label of largest neighbor.
float concavity_tolerance_threshold_
*** Parameters *** ///
float seed_resolution_
Seed resolution of the supervoxels (used only for smoothness check)
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.
SupervoxelAdjacencyList sv_adjacency_list_
Adjacency graph with the supervoxel labels as nodes and edges between adjacent supervoxels.
typename boost::graph_traits< SupervoxelAdjacencyList >::edge_descriptor EdgeID
std::map< std::uint32_t, typename pcl::Supervoxel< PointT >::Ptr > sv_label_to_supervoxel_map_
map from the supervoxel labels to the supervoxel objects
shared_ptr< const PointCloud< PointT > > ConstPtr
SampleConsensus represents the base class.
SampleConsensusModelPtr sac_model_
The underlying data model used (i.e.
int max_iterations_
Maximum number of iterations before giving up.
shared_ptr< SampleConsensusModel< PointT > > Ptr
Defines all the PCL implemented PointT point type structures.
shared_ptr< Indices > IndicesPtr
A point structure representing Euclidean xyz coordinates, intensity, together with normal coordinates...