39 #ifndef PCL_MIN_CUT_SEGMENTATION_H_
40 #define PCL_MIN_CUT_SEGMENTATION_H_
42 #include <pcl/segmentation/boost.h>
43 #if (BOOST_VERSION >= 104400)
44 #include <pcl/pcl_base.h>
45 #include <pcl/point_cloud.h>
46 #include <pcl/point_types.h>
47 #include <pcl/search/search.h>
58 template <
typename Po
intT>
59 class PCL_EXPORTS MinCutSegmentation :
public pcl::PCLBase<PointT>
68 using PCLBase <PointT>::input_;
69 using PCLBase <PointT>::indices_;
70 using PCLBase <PointT>::initCompute;
71 using PCLBase <PointT>::deinitCompute;
75 typedef boost::adjacency_list_traits< boost::vecS, boost::vecS, boost::directedS > Traits;
77 typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS,
78 boost::property< boost::vertex_name_t, std::string,
79 boost::property< boost::vertex_index_t, long,
80 boost::property< boost::vertex_color_t, boost::default_color_type,
81 boost::property< boost::vertex_distance_t, long,
82 boost::property< boost::vertex_predecessor_t, Traits::edge_descriptor > > > > >,
83 boost::property< boost::edge_capacity_t, double,
84 boost::property< boost::edge_residual_capacity_t, double,
85 boost::property< boost::edge_reverse_t, Traits::edge_descriptor > > > > mGraph;
87 typedef boost::property_map< mGraph, boost::edge_capacity_t >::type CapacityMap;
89 typedef boost::property_map< mGraph, boost::edge_reverse_t>::type ReverseEdgeMap;
91 typedef Traits::vertex_descriptor VertexDescriptor;
93 typedef boost::graph_traits< mGraph >::edge_descriptor EdgeDescriptor;
95 typedef boost::graph_traits< mGraph >::out_edge_iterator OutEdgeIterator;
97 typedef boost::graph_traits< mGraph >::vertex_iterator VertexIterator;
99 typedef boost::property_map< mGraph, boost::edge_residual_capacity_t >::type ResidualCapacityMap;
101 typedef boost::property_map< mGraph, boost::vertex_index_t >::type IndexMap;
103 typedef boost::graph_traits< mGraph >::in_edge_iterator InEdgeIterator;
108 MinCutSegmentation ();
112 ~MinCutSegmentation ();
118 setInputCloud (
const PointCloudConstPtr &cloud);
128 setSigma (
double sigma);
138 setRadius (
double radius);
142 getSourceWeight ()
const;
148 setSourceWeight (
double weight);
154 getSearchMethod ()
const;
161 setSearchMethod (
const KdTreePtr& tree);
165 getNumberOfNeighbours ()
const;
171 setNumberOfNeighbours (
unsigned int neighbour_number);
174 std::vector<PointT, Eigen::aligned_allocator<PointT> >
175 getForegroundPoints ()
const;
184 std::vector<PointT, Eigen::aligned_allocator<PointT> >
185 getBackgroundPoints ()
const;
199 extract (std::vector <pcl::PointIndices>& clusters);
206 typename boost::shared_ptr<typename pcl::MinCutSegmentation<PointT>::mGraph>
226 calculateUnaryPotential (
int point,
double& source_weight,
double& sink_weight)
const;
234 addEdge (
int source,
int target,
double weight);
242 calculateBinaryPotential (
int source,
int target)
const;
246 recalculateUnaryPotentials ();
250 recalculateBinaryPotentials ();
256 assembleLabels (ResidualCapacityMap& residual_capacity);
261 double inverse_sigma_;
264 bool binary_potentials_are_valid_;
273 bool unary_potentials_are_valid_;
276 double source_weight_;
282 unsigned int number_of_neighbours_;
285 bool graph_is_valid_;
288 std::vector<PointT, Eigen::aligned_allocator<PointT> > foreground_points_;
291 std::vector<PointT, Eigen::aligned_allocator<PointT> > background_points_;
294 std::vector <pcl::PointIndices> clusters_;
297 boost::shared_ptr<mGraph> graph_;
300 boost::shared_ptr<CapacityMap> capacity_;
303 boost::shared_ptr<ReverseEdgeMap> reverse_edges_;
306 std::vector< VertexDescriptor > vertices_;
309 std::vector< std::set<int> > edge_marker_;
312 VertexDescriptor source_;
315 VertexDescriptor sink_;
321 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
325 #ifdef PCL_NO_PRECOMPILE
326 #include <pcl/segmentation/impl/min_cut_segmentation.hpp>
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
boost::shared_ptr< PointCloud< PointT > > Ptr
boost::shared_ptr< KdTree< PointT > > Ptr