Point Cloud Library (PCL)  1.9.1
crf_segmentation.hpp
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the copyright holder(s) nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * Author : Christian Potthast
36  * Email : potthast@usc.edu
37  *
38  */
39 
40 #ifndef PCL_CRF_SEGMENTATION_HPP_
41 #define PCL_CRF_SEGMENTATION_HPP_
42 
43 #include <pcl/segmentation/crf_segmentation.h>
44 
45 #include <pcl/common/io.h>
46 
47 #include <stdio.h>
48 #include <stdlib.h>
49 #include <time.h>
50 
51 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52 template <typename PointT>
54  voxel_grid_ (),
55  input_cloud_ (new pcl::PointCloud<PointT>),
56  normal_cloud_ (new pcl::PointCloud<pcl::PointNormal>),
57  filtered_cloud_ (new pcl::PointCloud<PointT>),
58  filtered_anno_ (new pcl::PointCloud<pcl::PointXYZRGBL>),
59  filtered_normal_ (new pcl::PointCloud<pcl::PointNormal>),
60  voxel_grid_leaf_size_ (Eigen::Vector4f (0.001f, 0.001f, 0.001f, 0.0f))
61 {
62 }
63 
64 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
65 template <typename PointT>
67 {
68 }
69 
70 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
71 template <typename PointT> void
73 {
74  if (input_cloud_ != NULL)
75  input_cloud_.reset ();
76 
77  input_cloud_ = input_cloud;
78 }
79 
80 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
81 template <typename PointT> void
83 {
84  if (anno_cloud_ != NULL)
85  anno_cloud_.reset ();
86 
87  anno_cloud_ = anno_cloud;
88 }
89 
90 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
91 template <typename PointT> void
93 {
94  if (normal_cloud_ != NULL)
95  normal_cloud_.reset ();
96 
97  normal_cloud_ = normal_cloud;
98 }
99 
100 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
101 template <typename PointT> void
102 pcl::CrfSegmentation<PointT>::setVoxelGridLeafSize (const float x, const float y, const float z)
103 {
104  voxel_grid_leaf_size_.x () = x;
105  voxel_grid_leaf_size_.y () = y;
106  voxel_grid_leaf_size_.z () = z;
107 }
108 
109 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
110 template <typename PointT> void
111 pcl::CrfSegmentation<PointT>::setSmoothnessKernelParameters (const float sx, const float sy, const float sz,
112  const float w)
113 {
114  smoothness_kernel_param_[0] = sx;
115  smoothness_kernel_param_[1] = sy;
116  smoothness_kernel_param_[2] = sz;
117  smoothness_kernel_param_[3] = w;
118 }
119 
120 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
121 template <typename PointT> void
123  float sr, float sg, float sb,
124  float w)
125 {
126  appearance_kernel_param_[0] = sx;
127  appearance_kernel_param_[1] = sy;
128  appearance_kernel_param_[2] = sz;
129  appearance_kernel_param_[3] = sr;
130  appearance_kernel_param_[4] = sg;
131  appearance_kernel_param_[5] = sb;
132  appearance_kernel_param_[6] = w;
133 }
134 
135 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
136 template <typename PointT> void
138  float snx, float sny, float snz,
139  float w)
140 {
141  surface_kernel_param_[0] = sx;
142  surface_kernel_param_[1] = sy;
143  surface_kernel_param_[2] = sz;
144  surface_kernel_param_[3] = snx;
145  surface_kernel_param_[4] = sny;
146  surface_kernel_param_[5] = snz;
147  surface_kernel_param_[6] = w;
148 }
149 
150 
151 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
152 template <typename PointT> void
154 {
155  // Filter the input cloud
156  // Set the voxel grid input cloud
157  voxel_grid_.setInputCloud (input_cloud_);
158  // Set the voxel grid leaf size
159  voxel_grid_.setLeafSize (voxel_grid_leaf_size_.x (), voxel_grid_leaf_size_.y (), voxel_grid_leaf_size_.z () );
160  // Only downsample XYZ (if this is set to false, color values set to 0)
161  voxel_grid_.setDownsampleAllData (true);
162  // Save leaf information
163  //voxel_grid_.setSaveLeafLayout (true);
164  // apply the filter
165  voxel_grid_.filter (*filtered_cloud_);
166 
167  // Filter the annotated cloud
168  if (anno_cloud_->points.size () > 0)
169  {
171 
172  vg.setInputCloud (anno_cloud_);
173  // Set the voxel grid leaf size
174  vg.setLeafSize (voxel_grid_leaf_size_.x (), voxel_grid_leaf_size_.y (), voxel_grid_leaf_size_.z () );
175  // Only downsample XYZ
176  vg.setDownsampleAllData (true);
177  // Save leaf information
178  //vg.setSaveLeafLayout (false);
179  // apply the filter
180  vg.filter (*filtered_anno_);
181  }
182 
183  // Filter the annotated cloud
184  if (normal_cloud_->points.size () > 0)
185  {
187  vg.setInputCloud (normal_cloud_);
188  // Set the voxel grid leaf size
189  vg.setLeafSize (voxel_grid_leaf_size_.x (), voxel_grid_leaf_size_.y (), voxel_grid_leaf_size_.z () );
190  // Only downsample XYZ
191  vg.setDownsampleAllData (true);
192  // Save leaf information
193  //vg.setSaveLeafLayout (false);
194  // apply the filter
195  vg.filter (*filtered_normal_);
196  }
197 
198 }
199 
200 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
201 template <typename PointT> void
203 {
204  // get the dimension of the voxel grid
205  //Eigen::Vector3i min_b, max_b;
206  //min_b = voxel_grid_.getMinBoxCoordinates ();
207  //max_b = voxel_grid_.getMaxBoxCoordinates ();
208 
209  //std::cout << "min_b: " << min_b.x () << " " << min_b.y () << " " << min_b.z () << std::endl;
210  //std::cout << "max_b: " << max_b.x () << " " << max_b.y () << " " << max_b.z () << std::endl;
211 
212  // compute the voxel grid dimensions
213  //dim_.x () = abs (max_b.x () - min_b.x ());
214  //dim_.y () = abs (max_b.y () - min_b.y ());
215  //dim_.z () = abs (max_b.z () - min_b.z ());
216 
217  //std::cout << dim_.x () * dim_.y () * dim_.z () << std::endl;
218 
219  // reserve the space for the data vector
220  //data_.reserve (dim_.x () * dim_.y () * dim_.z ());
221 
222 /*
223  std::vector<Eigen::Vector3i, Eigen::aligned_allocator<Eigen::Vector3i> > data;
224  std::vector<Eigen::Vector3i, Eigen::aligned_allocator<Eigen::Vector3i> > color;
225  // fill the data vector
226  for (int kk = min_b.z (), k = 0; kk <= max_b.z (); kk++, k++)
227  {
228  for (int jj = min_b.y (), j = 0; jj <= max_b.y (); jj++, j++)
229  {
230  for (int ii = min_b.x (), i = 0; ii <= max_b.x (); ii++, i++)
231  {
232  Eigen::Vector3i ijk (ii, jj, kk);
233  int index = voxel_grid_.getCentroidIndexAt (ijk);
234  if (index != -1)
235  {
236  data_.push_back (Eigen::Vector3i (i, j, k));
237  color_.push_back (input_cloud_->points[index].getRGBVector3i ());
238  }
239  }
240  }
241  }
242 */
243 
244 
245 /*
246  // get the size of the input fields
247  std::vector< pcl::PCLPointField > fields;
248  pcl::getFields (*input_cloud_, fields);
249 
250  for (int i = 0; i < fields.size (); i++)
251  std::cout << fields[i] << std::endl;
252 */
253 
254 
255  // reserve space for the data vector
256  data_.resize (filtered_cloud_->points.size ());
257 
258  std::vector< pcl::PCLPointField > fields;
259  // check if we have color data
260  bool color_data = false;
261  int rgba_index = -1;
262  rgba_index = pcl::getFieldIndex (*input_cloud_, "rgb", fields);
263  if (rgba_index == -1)
264  rgba_index = pcl::getFieldIndex (*input_cloud_, "rgba", fields);
265  if (rgba_index >= 0)
266  {
267  color_data = true;
268  color_.resize (filtered_cloud_->points.size ());
269  }
270 
271 
272 /*
273  // check if we have normal data
274  bool normal_data = false;
275  int normal_index = -1;
276  rgba_index = pcl::getFieldIndex (*input_cloud_, "normal_x", fields);
277  if (rgba_index >= 0)
278  {
279  normal_data = true;
280  normal_.resize (filtered_cloud_->points.size ());
281  }
282 */
283 
284  // fill the data vector
285  for (size_t i = 0; i < filtered_cloud_->points.size (); i++)
286  {
287  Eigen::Vector3f p (filtered_anno_->points[i].x,
288  filtered_anno_->points[i].y,
289  filtered_anno_->points[i].z);
290  Eigen::Vector3i c = voxel_grid_.getGridCoordinates (p.x (), p.y (), p.y ());
291  data_[i] = c;
292 
293  if (color_data)
294  {
295  uint32_t rgb = *reinterpret_cast<int*>(&filtered_cloud_->points[i].rgba);
296  uint8_t r = (rgb >> 16) & 0x0000ff;
297  uint8_t g = (rgb >> 8) & 0x0000ff;
298  uint8_t b = (rgb) & 0x0000ff;
299  color_[i] = Eigen::Vector3i (r, g, b);
300  }
301 
302 /*
303  if (normal_data)
304  {
305  float n_x = filtered_cloud_->points[i].normal_x;
306  float n_y = filtered_cloud_->points[i].normal_y;
307  float n_z = filtered_cloud_->points[i].normal_z;
308  normal_[i] = Eigen::Vector3f (n_x, n_y, n_z);
309  }
310 */
311  }
312 
313  normal_.resize (filtered_normal_->points.size ());
314  for (size_t i = 0; i < filtered_normal_->points.size (); i++)
315  {
316  float n_x = filtered_normal_->points[i].normal_x;
317  float n_y = filtered_normal_->points[i].normal_y;
318  float n_z = filtered_normal_->points[i].normal_z;
319  normal_[i] = Eigen::Vector3f (n_x, n_y, n_z);
320  }
321 
322 
323 }
324 
325 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
326 template <typename PointT> void
328  std::vector<int> &labels,
329  unsigned int n_labels)
330 {
331  /* initialize random seed: */
332  srand ( static_cast<unsigned int> (time (NULL)) );
333  //srand ( time (NULL) );
334 
335  // Certainty that the groundtruth is correct
336  const float GT_PROB = 0.9f;
337  const float u_energy = -logf ( 1.0f / static_cast<float> (n_labels) );
338  const float n_energy = -logf ( (1.0f - GT_PROB) / static_cast<float>(n_labels - 1) );
339  const float p_energy = -logf ( GT_PROB );
340 
341  for (size_t k = 0; k < filtered_anno_->points.size (); k++)
342  {
343  int label = filtered_anno_->points[k].label;
344 
345  if (labels.size () == 0 && label > 0)
346  labels.push_back (label);
347 
348  // add color to the color vector if not added yet
349  int c_idx;
350  for (c_idx = 0; c_idx < static_cast<int> (labels.size ()) ; c_idx++)
351  {
352  if (labels[c_idx] == label)
353  break;
354 
355  if (c_idx == static_cast<int>(labels.size () -1) && label > 0)
356  {
357  if (labels.size () < n_labels)
358  labels.push_back (label);
359  else
360  label = 0;
361  }
362  }
363 
364  /* generate secret number: */
365  //double iSecret = static_cast<double> (rand ()) / static_cast<double> (RAND_MAX);
366 
367  /*
368  if (k < 100)
369  std::cout << iSecret << std::endl;
370  */
371 
372 /*
373  int gg = 5; //static_cast<int> (labels.size ());
374  if (iSecret < 0.5)
375  {
376  int r = 0;
377  if (gg != 0)
378  r = rand () % (gg - 1 + 1) + 1;
379  else
380  r = 0;
381  c_idx = r;
382  }
383 */
384 
385  // set the engeries for the labels
386  size_t u_idx = k * n_labels;
387  if (label > 0)
388  {
389  for (size_t i = 0; i < n_labels; i++)
390  unary[u_idx + i] = n_energy;
391  unary[u_idx + c_idx] = p_energy;
392 
393  if (label == 1)
394  {
395  const float PROB = 0.2f;
396  const float n_energy2 = -logf ( (1.0f - PROB) / static_cast<float>(n_labels - 1) );
397  const float p_energy2 = -logf ( PROB );
398 
399  for (size_t i = 0; i < n_labels; i++)
400  unary[u_idx + i] = n_energy2;
401  unary[u_idx + c_idx] = p_energy2;
402  }
403 
404  }
405  else
406  {
407  for (size_t i = 0; i < n_labels; i++)
408  unary[u_idx + i] = u_energy;
409  }
410  }
411 }
412 
413 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
414 template <typename PointT> void
416 {
417  // create the voxel grid
418  createVoxelGrid ();
419  std::cout << "create Voxel Grid - DONE" << std::endl;
420 
421  // create the data Vector
422  createDataVectorFromVoxelGrid ();
423  std::cout << "create Data Vector from Voxel Grid - DONE" << std::endl;
424 
425  // number of labels
426  const int n_labels = 10;
427  // number of data points
428  int N = static_cast<int> (data_.size ());
429 
430  // create unary potentials
431  std::vector<int> labels;
432  std::vector<float> unary;
433  if (anno_cloud_->points.size () > 0)
434  {
435  unary.resize (N * n_labels);
436  createUnaryPotentials (unary, labels, n_labels);
437 
438 
439  std::cout << "labels size: " << labels.size () << std::endl;
440  for (size_t i = 0; i < labels.size (); i++)
441  {
442  std::cout << labels[i] << std::endl;
443  }
444 
445  }
446  std::cout << "create unary potentials - DONE" << std::endl;
447 
448 
449 /*
450  pcl::PointCloud<pcl::PointXYZRGBL> tmp_cloud_OLD;
451  tmp_cloud_OLD = *filtered_anno_;
452 
453  // Setup the CRF model
454  DenseCRF2D crfOLD(N, 1, n_labels);
455 
456  float * unaryORI = new float[N*n_labels];
457  for (int i = 0; i < N*n_labels; i++)
458  unaryORI[i] = unary[i];
459  crfOLD.setUnaryEnergy( unaryORI );
460 
461  float * pos = new float[N*3];
462  for (int i = 0; i < N; i++)
463  {
464  pos[i * 3] = data_[i].x ();
465  pos[i * 3 +1] = data_[i].y ();
466  pos[i * 3 +2] = data_[i].z ();
467  }
468  crfOLD.addPairwiseGaussian( pos, 3, 3, 3, 2.0 );
469 
470  float * col = new float[N*3];
471  for (int i = 0; i < N; i++)
472  {
473  col[i * 3] = color_[i].x ();
474  col[i * 3 +1] = color_[i].y ();
475  col[i * 3 +2] = color_[i].z ();
476  }
477  crfOLD.addPairwiseBilateral(pos, col, 20, 20, 20, 10, 10, 10, 1.3 );
478 
479  short * map = new short[N];
480  crfOLD.map(10, map);
481 
482  for (size_t i = 0; i < N; i++)
483  {
484  tmp_cloud_OLD.points[i].label = map[i];
485  }
486 
487 
488 */
489 
490  //float * resultOLD = new float[N*n_labels];
491  //crfOLD.inference (10, resultOLD);
492 
493  //std::vector<float> baryOLD;
494  //crfOLD.getBarycentric (0, baryOLD);
495  //std::vector<float> featuresOLD;
496  //crfOLD.getFeature (1, featuresOLD);
497 
498 /*
499  for(int i = 0; i < 25; i++)
500  {
501  std::cout << baryOLD[i] << std::endl;
502  }
503 */
504 
505 
506  // create the output cloud
507  //output = *filtered_anno_;
508 
509 
510 
511  // ----------------------------------//
512  // -------- -------------------//
513 
515  tmp_cloud = *filtered_anno_;
516 
517  // create dense CRF
518  DenseCrf crf (N, n_labels);
519 
520  // set the unary potentials
521  crf.setUnaryEnergy (unary);
522 
523  // set the data vector
524  crf.setDataVector (data_);
525 
526  // set the color vector
527  crf.setColorVector (color_);
528 
529  std::cout << "create dense CRF - DONE" << std::endl;
530 
531 
532  // add the smoothness kernel
533  crf.addPairwiseGaussian (smoothness_kernel_param_[0],
534  smoothness_kernel_param_[1],
535  smoothness_kernel_param_[2],
536  smoothness_kernel_param_[3]);
537  std::cout << "add smoothness kernel - DONE" << std::endl;
538 
539  // add the appearance kernel
540  crf.addPairwiseBilateral (appearance_kernel_param_[0],
541  appearance_kernel_param_[1],
542  appearance_kernel_param_[2],
543  appearance_kernel_param_[3],
544  appearance_kernel_param_[4],
545  appearance_kernel_param_[5],
546  appearance_kernel_param_[6]);
547  std::cout << "add appearance kernel - DONE" << std::endl;
548 
549  crf.addPairwiseNormals (data_, normal_,
550  surface_kernel_param_[0],
551  surface_kernel_param_[1],
552  surface_kernel_param_[2],
553  surface_kernel_param_[3],
554  surface_kernel_param_[4],
555  surface_kernel_param_[5],
556  surface_kernel_param_[6]);
557  std::cout << "add surface kernel - DONE" << std::endl;
558 
559  // map inference
560  std::vector<int> r (N);
561  crf.mapInference (n_iterations_, r);
562 
563  //std::vector<float> result (N*n_labels);
564  //crf.inference (n_iterations_, result);
565 
566  //std::vector<float> bary;
567  //crf.getBarycentric (0, bary);
568  //std::vector<float> features;
569  //crf.getFeatures (1, features);
570 
571  std::cout << "Map inference - DONE" << std::endl;
572 
573  // create the output cloud
574  output = *filtered_anno_;
575 
576  for (int i = 0; i < N; i++)
577  {
578  output.points[i].label = labels[r[i]];
579  }
580 
581 
582 /*
583  bool c = true;
584  for (size_t i = 0; i < tmp_cloud.points.size (); i++)
585  {
586  if (tmp_cloud.points[i].label != tmp_cloud_OLD.points[i].label)
587  {
588 
589  std::cout << "idx: " << i << " = " <<tmp_cloud.points[i].label << " | " << tmp_cloud_OLD.points[i].label << std::endl;
590  c = false;
591  break;
592  }
593  }
594 
595  if (c)
596  std::cout << "DEBUG - OUTPUT - OK" << std::endl;
597  else
598  std::cout << "DEBUG - OUTPUT - ERROR" << std::endl;
599 */
600 
601 
602 
603 /*
604  for (size_t i = 0; i < 25; i++)
605  {
606  std::cout << result[i] << " | " << resultOLD[i] << std::endl;
607  }
608 
609 
610  c = true;
611  for (size_t i = 0; i < result.size (); i++)
612  {
613  if (result[i] != resultOLD[i])
614  {
615  std::cout << result[i] << " | " << resultOLD[i] << std::endl;
616 
617  c = false;
618  break;
619  }
620  }
621 
622  if (c)
623  std::cout << "DEBUG - OUTPUT - OK" << std::endl;
624  else
625  std::cout << "DEBUG - OUTPUT - ERROR" << std::endl;
626 */
627 
628 
629 }
630 
631 #define PCL_INSTANTIATE_CrfSegmentation(T) template class pcl::CrfSegmentation<T>;
632 
633 #endif // PCL_CRF_SEGMENTATION_HPP_
pcl::VoxelGrid
VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
Definition: voxel_grid.h:178
pcl::DenseCrf
Definition: densecrf.h:53
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::PointCloud::Ptr
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
Eigen
Definition: bfgs.h:10
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition: point_cloud.h:410
pcl::VoxelGrid::setDownsampleAllData
void setDownsampleAllData(bool downsample)
Set to true if all fields need to be downsampled, or false if just XYZ.
Definition: voxel_grid.h:258
pcl::DenseCrf::addPairwiseGaussian
void addPairwiseGaussian(float sx, float sy, float sz, float w)
Add a pairwise gaussian kernel.
pcl::VoxelGrid::setLeafSize
void setLeafSize(const Eigen::Vector4f &leaf_size)
Set the voxel grid leaf size.
Definition: voxel_grid.h:224
pcl::PointXYZRGBL
Definition: point_types.hpp:650
pcl::DenseCrf::addPairwiseBilateral
void addPairwiseBilateral(float sx, float sy, float sz, float sr, float sg, float sb, float w)
Add a bilateral gaussian kernel.
pcl::DenseCrf::mapInference
void mapInference(int n_iterations, std::vector< int > &result, float relax=1.0f)
pcl::DenseCrf::addPairwiseNormals
void addPairwiseNormals(std::vector< Eigen::Vector3i, Eigen::aligned_allocator< Eigen::Vector3i > > &coord, std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > &normals, float sx, float sy, float sz, float snx, float sny, float snz, float w)
pcl::CrfSegmentation::segmentPoints
void segmentPoints(pcl::PointCloud< pcl::PointXYZRGBL > &output)
This method simply launches the segmentation algorithm.
Definition: crf_segmentation.hpp:415
pcl::Filter::filter
void filter(PointCloud &output)
Calls the filtering method and returns the filtered dataset in output.
Definition: filter.h:132
pcl::CrfSegmentation::setAnnotatedCloud
void setAnnotatedCloud(typename pcl::PointCloud< pcl::PointXYZRGBL >::Ptr anno_cloud)
Definition: crf_segmentation.hpp:82
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: projection_matrix.h:53
pcl::CrfSegmentation::setSmoothnessKernelParameters
void setSmoothnessKernelParameters(const float sx, const float sy, const float sz, const float w)
Set the smoothness kernel parameters.
Definition: crf_segmentation.hpp:111
pcl::PCLBase::setInputCloud
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
Definition: pcl_base.hpp:66
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:619
pcl::getFieldIndex
int getFieldIndex(const pcl::PCLPointCloud2 &cloud, const std::string &field_name)
Get the index of a specified field (i.e., dimension/channel)
Definition: io.h:59
pcl::CrfSegmentation::createVoxelGrid
void createVoxelGrid()
Create a voxel grid to discretize the scene.
Definition: crf_segmentation.hpp:153
pcl::DenseCrf::setUnaryEnergy
void setUnaryEnergy(const std::vector< float > unary)
pcl::DenseCrf::setColorVector
void setColorVector(const std::vector< Eigen::Vector3i, Eigen::aligned_allocator< Eigen::Vector3i > > color)
The associated color of the data.
pcl::CrfSegmentation::setAppearanceKernelParameters
void setAppearanceKernelParameters(float sx, float sy, float sz, float sr, float sg, float sb, float w)
Set the appearanche kernel parameters.
Definition: crf_segmentation.hpp:122
pcl::CrfSegmentation::createUnaryPotentials
void createUnaryPotentials(std::vector< float > &unary, std::vector< int > &colors, unsigned int n_labels)
Definition: crf_segmentation.hpp:327
pcl::CrfSegmentation::setInputCloud
void setInputCloud(typename pcl::PointCloud< PointT >::Ptr input_cloud)
This method sets the input cloud.
Definition: crf_segmentation.hpp:72
pcl::CrfSegmentation::~CrfSegmentation
~CrfSegmentation()
This destructor destroys the cloud...
Definition: crf_segmentation.hpp:66
pcl::PointNormal
A point structure representing Euclidean xyz coordinates, together with normal coordinates and the su...
Definition: point_types.hpp:871
pcl::VoxelGridLabel
Definition: voxel_grid_label.h:51
pcl::CrfSegmentation::setVoxelGridLeafSize
void setVoxelGridLeafSize(const float x, const float y, const float z)
Set the leaf size for the voxel grid.
Definition: crf_segmentation.hpp:102
pcl::CrfSegmentation::setNormalCloud
void setNormalCloud(typename pcl::PointCloud< pcl::PointNormal >::Ptr normal_cloud)
Definition: crf_segmentation.hpp:92
pcl::CrfSegmentation::createDataVectorFromVoxelGrid
void createDataVectorFromVoxelGrid()
Get the data from the voxel grid and convert it into a vector.
Definition: crf_segmentation.hpp:202
pcl::CrfSegmentation::CrfSegmentation
CrfSegmentation()
Constructor that sets default values for member variables.
Definition: crf_segmentation.hpp:53
pcl::CrfSegmentation::setSurfaceKernelParameters
void setSurfaceKernelParameters(float sx, float sy, float sz, float snx, float sny, float snz, float w)
Definition: crf_segmentation.hpp:137
pcl::DenseCrf::setDataVector
void setDataVector(const std::vector< Eigen::Vector3i, Eigen::aligned_allocator< Eigen::Vector3i > > data)
set the input data vector.