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/segmentation/extract_clusters.h>
52 #define PCL_INSTANTIATE_CPCSegmentation(T) template class PCL_EXPORTS pcl::CPCSegmentation<T>;
65 template <
typename Po
intT>
108 const std::uint32_t cutting_min_segments = 0,
109 const float cutting_min_score = 0.16,
110 const bool locally_constrained =
true,
111 const bool directed_cutting =
true,
112 const bool clean_cutting =
false)
114 max_cuts_ = max_cuts;
115 min_segment_size_for_cutting_ = cutting_min_segments;
116 min_cut_score_ = cutting_min_score;
117 use_local_constrains_ = locally_constrained;
118 use_directed_weights_ = directed_cutting;
119 use_clean_cutting_ = clean_cutting;
127 ransac_itrs_ = ransac_iterations;
136 applyCuttingPlane (std::uint32_t depth_levels_left);
141 std::uint32_t max_cuts_;
144 std::uint32_t min_segment_size_for_cutting_;
147 float min_cut_score_;
150 bool use_local_constrains_;
153 bool use_directed_weights_;
156 bool use_clean_cutting_;
159 std::uint32_t ransac_itrs_;
174 class WeightedRandomSampleConsensus :
public SampleConsensus<WeightSACPointType>
179 using Ptr = shared_ptr<WeightedRandomSampleConsensus>;
180 using ConstPtr = shared_ptr<const WeightedRandomSampleConsensus>;
186 WeightedRandomSampleConsensus (
const SampleConsensusModelPtr &model,
198 WeightedRandomSampleConsensus (
const SampleConsensusModelPtr &model,
201 : SampleConsensus<WeightSACPointType> (model, threshold, random)
210 computeModel (
int debug_verbosity_level = 0)
override;
216 setWeights (
const std::vector<double> &weights,
217 const bool directed_weights =
false)
219 if (weights.size () != full_cloud_pt_indices_->size ())
221 PCL_ERROR (
"[pcl::WeightedRandomSampleConsensus::setWeights] Cannot assign weights. Weight vector needs to have the same length as the input pointcloud\n");
225 model_pt_indices_->clear ();
226 for (std::size_t i = 0; i < weights.size (); ++i)
228 if (weights[i] > std::numeric_limits<double>::epsilon ())
229 model_pt_indices_->push_back (i);
231 use_directed_weights_ = directed_weights;
238 getBestScore ()
const
240 return (best_score_);
250 use_directed_weights_ =
false;
251 model_pt_indices_.reset (
new Indices);
253 point_cloud_ptr_ =
sac_model_->getInputCloud ();
257 bool use_directed_weights_;
260 std::vector<double> weights_;
278 #ifdef PCL_NO_PRECOMPILE
279 #include <pcl/segmentation/impl/cpc_segmentation.hpp>
280 #elif defined(PCL_ONLY_CORE_POINT_TYPES)
282 #include <pcl/sample_consensus/impl/sac_model_plane.hpp>
283 #include <pcl/segmentation/impl/extract_clusters.hpp>
284 #endif // PCL_NO_PRECOMPILE / PCL_ONLY_CORE_POINT_TYPES