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_