40 #ifndef PCL_SEGMENTATION_GRABCUT
41 #define PCL_SEGMENTATION_GRABCUT
43 #include <pcl/point_cloud.h>
44 #include <pcl/pcl_base.h>
45 #include <pcl/point_types.h>
46 #include <pcl/segmentation/boost.h>
47 #include <pcl/search/search.h>
51 namespace segmentation
95 addEdge (
int u,
int v,
double cap_uv,
double cap_vu = 0.0);
115 typedef std::pair<capacitated_edge::iterator, capacitated_edge::iterator>
edge_pair;
127 augmentPath (
const std::pair<int, int>& path, std::deque<int>& orphans);
138 isActive (
int u)
const {
return ((u == active_head_) || (active_list_[u].first != TERMINAL)); }
154 std::vector<unsigned char>
cut_;
158 static const int TERMINAL = -1;
160 std::vector<std::pair<int, edge_pair> > parents_;
162 std::vector<std::pair<int, int> > active_list_;
163 int active_head_, active_tail_;
170 Color (
float _r,
float _g,
float _b) :
r(_r),
g(_g),
b(_b) {}
173 template<
typename Po
intT>
176 r =
static_cast<float> (p.r);
177 g =
static_cast<float> (p.g);
178 b =
static_cast<float> (p.b);
181 template<
typename Po
intT>
185 p.r =
static_cast<uint32_t
> (
r);
186 p.g =
static_cast<uint32_t
> (
g);
187 p.b =
static_cast<uint32_t
> (
b);
230 GMM () : gaussians_ (0) {}
232 GMM (std::size_t
K) : gaussians_ (K) {}
237 getK ()
const {
return gaussians_.size (); }
240 resize (std::size_t
K) { gaussians_.resize (K); }
246 operator[] (std::size_t pos)
const {
return (gaussians_[pos]); }
256 std::vector<Gaussian> gaussians_;
264 : sum_ (Eigen::Vector3f::Zero ())
265 , accumulator_ (Eigen::Matrix3f::Zero ())
275 fit (
Gaussian& g, std::size_t total_count,
bool compute_eigens =
false)
const;
288 Eigen::Vector3f sum_;
290 Eigen::Matrix3f accumulator_;
300 const std::vector<int>& indices,
301 const std::vector<SegmentationValue> &hardSegmentation,
302 std::vector<std::size_t> &components,
303 GMM &background_GMM, GMM &foreground_GMM);
307 const std::vector<int>& indices,
308 const std::vector<SegmentationValue>& hard_segmentation,
309 std::vector<std::size_t>& components,
310 GMM& background_GMM, GMM& foreground_GMM);
322 template <
typename Po
intT>
399 extract (std::vector<pcl::PointIndices>& clusters);
431 computeNLink (uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2);
475 std::vector<segmentation::grabcut::TrimapValue>
trimap_;
489 #include <pcl/segmentation/impl/grabcut.hpp>