38 #ifndef PCL_SEGMENTATION_CPC_SEGMENTATION_H_ 39 #define PCL_SEGMENTATION_CPC_SEGMENTATION_H_ 42 #include <pcl/pcl_base.h> 44 #include <pcl/point_cloud.h> 47 #include <pcl/segmentation/supervoxel_clustering.h> 48 #include <pcl/segmentation/lccp_segmentation.h> 49 #include <pcl/sample_consensus/sac.h> 51 #include <pcl/sample_consensus/sac_model_plane.h> 52 #include <pcl/segmentation/extract_clusters.h> 54 #define PCL_INSTANTIATE_CPCSegmentation(T) template class PCL_EXPORTS pcl::CPCSegmentation<T>; 67 template <
typename Po
intT>
110 const uint32_t cutting_min_segments = 0,
111 const float cutting_min_score = 0.16,
112 const bool locally_constrained =
true,
113 const bool directed_cutting =
true,
114 const bool clean_cutting =
false)
116 max_cuts_ = max_cuts;
117 min_segment_size_for_cutting_ = cutting_min_segments;
118 min_cut_score_ = cutting_min_score;
119 use_local_constrains_ = locally_constrained;
120 use_directed_weights_ = directed_cutting;
121 use_clean_cutting_ = clean_cutting;
129 ransac_itrs_ = ransac_iterations;
138 applyCuttingPlane (uint32_t depth_levels_left);
146 uint32_t min_segment_size_for_cutting_;
149 float min_cut_score_;
152 bool use_local_constrains_;
155 bool use_directed_weights_;
158 bool use_clean_cutting_;
161 uint32_t ransac_itrs_;
176 class WeightedRandomSampleConsensus :
public SampleConsensus<WeightSACPointType>
181 typedef boost::shared_ptr<WeightedRandomSampleConsensus> Ptr;
182 typedef boost::shared_ptr<const WeightedRandomSampleConsensus> ConstPtr;
188 WeightedRandomSampleConsensus (
const SampleConsensusModelPtr &model,
200 WeightedRandomSampleConsensus (
const SampleConsensusModelPtr &model,
203 : SampleConsensus<WeightSACPointType> (model, threshold, random)
212 computeModel (
int debug_verbosity_level = 0);
218 setWeights (
const std::vector<double> &weights,
219 const bool directed_weights =
false)
221 if (weights.size () != full_cloud_pt_indices_->size ())
223 PCL_ERROR (
"[pcl::WeightedRandomSampleConsensus::setWeights] Cannot assign weights. Weight vector needs to have the same length as the input pointcloud\n");
227 model_pt_indices_->clear ();
228 for (
size_t i = 0; i < weights.size (); ++i)
230 if (weights[i] > std::numeric_limits<double>::epsilon ())
231 model_pt_indices_->push_back (i);
233 use_directed_weights_ = directed_weights;
240 getBestScore ()
const 242 return (best_score_);
252 use_directed_weights_ =
false;
253 model_pt_indices_ = boost::shared_ptr<std::vector<int> > (
new std::vector<int> ());
254 full_cloud_pt_indices_.reset (
new std::vector<int> (* (
sac_model_->getIndices ())));
255 point_cloud_ptr_ =
sac_model_->getInputCloud ();
259 bool use_directed_weights_;
262 std::vector<double> weights_;
265 boost::shared_ptr<std::vector<int> > model_pt_indices_;
268 boost::shared_ptr<std::vector<int> > full_cloud_pt_indices_;
271 boost::shared_ptr<const pcl::PointCloud<WeightSACPointType> > point_cloud_ptr_;
280 #ifdef PCL_NO_PRECOMPILE 281 #include <pcl/segmentation/impl/cpc_segmentation.hpp> 282 #elif defined(PCL_ONLY_CORE_POINT_TYPES) 284 #include <pcl/sample_consensus/impl/sac_model_plane.hpp> 285 #include <pcl/segmentation/impl/extract_clusters.hpp> 286 #endif // PCL_NO_PRECOMPILE / PCL_ONLY_CORE_POINT_TYPES 288 #endif // PCL_SEGMENTATION_CPC_SEGMENTATION_H_ 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 segment()
Merge supervoxels using cuts through local convexities.
This file defines compatibility wrappers for low level I/O functions.
A segmentation algorithm partitioning a supervoxel graph.
void setRANSACIterations(const uint32_t ransac_iterations)
Set the number of iterations for the weighted RANSAC step (best cut estimations)
uint32_t k_factor_
Factor used for k-convexity.
std::map< uint32_t, typename pcl::Supervoxel< PointT >::Ptr > sv_label_to_supervoxel_map_
map from the supervoxel labels to the supervoxel objects
SampleConsensusModel represents the base model class.
float seed_resolution_
Seed resolution of the supervoxels (used only for smoothness check)
Defines all the PCL implemented PointT point type structures.
A point structure representing Euclidean xyz coordinates, intensity, together with normal coordinates...
SampleConsensusModelPtr sac_model_
The underlying data model used (i.e.
boost::graph_traits< SupervoxelAdjacencyList >::edge_iterator EdgeIterator
bool supervoxels_set_
Marks if supervoxels have been set by calling setInputSupervoxels.
void mergeSmallSegments()
Segments smaller than min_segment_size_ are merged to the label of largest neighbor.
virtual ~CPCSegmentation()
boost::graph_traits< SupervoxelAdjacencyList >::edge_descriptor EdgeID
void setCutting(const uint32_t max_cuts=20, const 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.
std::map< uint32_t, uint32_t > sv_label_to_seg_label_map_
Storing relation between original SuperVoxel Labels and new segmantion labels.
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.
bool grouping_data_valid_
Marks if valid grouping data (sv_adjacency_list_, sv_label_to_seg_label_map_, processed_) is availabl...
int max_iterations_
Maximum number of iterations before giving up.
SampleConsensus represents the base class.
SupervoxelAdjacencyList sv_adjacency_list_
Adjacency graph with the supervoxel labels as nodes and edges between adjacent supervoxels.