30 #include <pcl/filters/extract_indices.h>
31 #include <pcl/filters/voxel_grid.h>
32 #include <pcl/filters/frustum_culling.h>
33 #include <pcl/filters/random_sample.h>
34 #include <pcl/filters/passthrough.h>
35 #include <pcl/filters/crop_box.h>
37 #include <pcl/features/normal_3d_omp.h>
39 #include <pcl/search/kdtree.h>
41 #include <pcl/common/common.h>
43 #include <pcl/segmentation/extract_clusters.h>
44 #include <pcl/segmentation/sac_segmentation.h>
53 #if PCL_VERSION_COMPARE(>=, 1, 8, 0)
54 #include <pcl/impl/instantiate.hpp>
55 #include <pcl/point_types.h>
56 #include <pcl/segmentation/impl/extract_clusters.hpp>
57 #include <pcl/segmentation/extract_labeled_clusters.h>
58 #include <pcl/segmentation/impl/extract_labeled_clusters.hpp>
59 #include <pcl/filters/impl/extract_indices.hpp>
61 PCL_INSTANTIATE(EuclideanClusterExtraction, (pcl::PointXYZRGBNormal));
62 PCL_INSTANTIATE(extractEuclideanClusters, (pcl::PointXYZRGBNormal));
63 PCL_INSTANTIATE(extractEuclideanClusters_indices, (pcl::PointXYZRGBNormal));
64 PCL_INSTANTIATE(ExtractIndices, (pcl::PointNormal));
82 float groundNormalsUp)
85 UDEBUG(
"scan size=%d format=%d, organized=%d, step=%d, rangeMin=%f, rangeMax=%f, voxel=%f, normalK=%d, normalRadius=%f, groundNormalsUp=%f",
86 scan.
size(), (
int)scan.
format(), scan.
isOrganized()?1:0, downsamplingStep, rangeMin, rangeMax, voxelSize, normalK, normalRadius, groundNormalsUp);
90 if(downsamplingStep<=1 || scan.
size() <= downsamplingStep)
95 if(downsamplingStep > 1 || rangeMin > 0.0
f || rangeMax > 0.0
f)
97 cv::Mat tmp = cv::Mat(1, scan.
size()/downsamplingStep, scan.
dataType());
98 bool is2d = scan.
is2d();
100 float rangeMinSqrd = rangeMin * rangeMin;
101 float rangeMaxSqrd = rangeMax * rangeMax;
102 int downsamplingRows = scan.
data().rows > scan.
data().cols?downsamplingStep:1;
103 int downsamplingCols = scan.
data().cols > scan.
data().rows?downsamplingStep:1;
104 for(
int j=0;
j<scan.
data().
rows-downsamplingRows+1;
j+=downsamplingRows)
106 for(
int i=0;
i<scan.
data().
cols-downsamplingCols+1;
i+=downsamplingCols)
108 const float * ptr = scan.
data().ptr<
float>(
j,
i);
110 if(rangeMin>0.0
f || rangeMax>0.0
f)
115 r = ptr[0]*ptr[0] + ptr[1]*ptr[1];
119 r = ptr[0]*ptr[0] + ptr[1]*ptr[1] + ptr[2]*ptr[2];
127 if(rangeMin > 0.0
f && r < rangeMinSqrd)
131 if(rangeMax > 0.0
f && r > rangeMaxSqrd)
137 cv::Mat(scan.
data(), cv::Range(
j,
j+1), cv::Range(
i,
i+1)).copyTo(cv::Mat(tmp,
cv::Range::all(), cv::Range(oi,oi+1)));
141 int previousSize = scan.
size();
159 scanMaxPtsTmp/downsamplingStep,
164 UDEBUG(
"Downsampling scan (step=%d): %d -> %d (scanMaxPts=%d->%d)", downsamplingStep, previousSize, scan.
size(), scanMaxPtsTmp, scan.
maxPoints());
167 if(scan.
size() && (voxelSize > 0.0f || ((normalK > 0 || normalRadius>0.0f) && !scan.
hasNormals())))
181 scanMaxPts =
int(
float(scanMaxPts) *
ratio);
182 UDEBUG(
"Voxel filtering scan (voxel=%f m): %d -> %d (scanMaxPts=%d->%d)", voxelSize, scan.
size(), cloud->size(), scan.
maxPoints(), scanMaxPts);
184 if(cloud->size() && (normalK > 0 || normalRadius>0.0f))
188 UDEBUG(
"Normals computed (k=%d radius=%f)", normalK, normalRadius);
191 UWARN(
"Only NaNs returned after normals estimation! The returned point cloud is empty. Normal k (%d) and/or radius (%f) may be too small.", normalK, normalRadius);
198 UWARN(
"Voxel filter is applied, but normal parameters are not set and input scan has normals. The returned scan has no normals.");
214 scanMaxPts =
int(
float(scanMaxPts) *
ratio);
215 UDEBUG(
"Voxel filtering scan (voxel=%f m): %d -> %d (scanMaxPts=%d->%d)", voxelSize, scan.
size(), cloud->size(), scan.
maxPoints(), scanMaxPts);
217 if(cloud->size() && (normalK > 0 || normalRadius>0.0f))
219 pcl::PointCloud<pcl::Normal>::Ptr normals;
233 UWARN(
"Only NaNs returned after normals estimation! The returned point cloud is empty. Normal k (%d) and/or radius (%f) may be too small.", normalK, normalRadius);
242 UWARN(
"Only NaNs returned after normals estimation! The returned point cloud is empty. Normal k (%d) and/or radius (%f) may be too small.", normalK, normalRadius);
245 UDEBUG(
"Normals computed (k=%d radius=%f)", normalK, normalRadius);
251 UWARN(
"Voxel filter is applied, but normal parameters are not set and input scan has normals. The returned scan has no normals.");
274 scanMaxPts =
int(
float(scanMaxPts) *
ratio);
275 UDEBUG(
"Voxel filtering scan (voxel=%f m): %d -> %d (scanMaxPts=%d->%d)", voxelSize, scan.
size(), cloud->size(), scan.
maxPoints(), scanMaxPts);
277 if(cloud->size() && (normalK > 0 || normalRadius>0.0f))
279 pcl::PointCloud<pcl::Normal>::Ptr normals;
293 UWARN(
"Only NaNs returned after normals estimation! The returned point cloud is empty. Normal k (%d) and/or radius (%f) may be too small.", normalK, normalRadius);
302 UWARN(
"Only NaNs returned after normals estimation! The returned point cloud is empty. Normal k (%d) and/or radius (%f) may be too small.", normalK, normalRadius);
305 UDEBUG(
"Normals computed (k=%d radius=%f)", normalK, normalRadius);
311 UWARN(
"Voxel filter i applied, but normal parameters are not set and input scan has normals. The returned scan has no normals.");
336 int downsamplingStep,
342 bool forceGroundNormalsUp)
344 return commonFiltering(scanIn, downsamplingStep, rangeMin, rangeMax, voxelSize, normalK, normalRadius, forceGroundNormalsUp?0.8
f:0.0
f);
352 UASSERT(rangeMin >=0.0
f && rangeMax>=0.0
f);
355 if(rangeMin > 0.0
f || rangeMax > 0.0
f)
357 cv::Mat output = cv::Mat(1, scan.
size(), scan.
dataType());
358 bool is2d = scan.
is2d();
360 float rangeMinSqrd = rangeMin * rangeMin;
361 float rangeMaxSqrd = rangeMax * rangeMax;
362 for(
int i=0;
i<scan.
size(); ++
i)
364 const float * ptr = scan.
data().ptr<
float>(0,
i);
368 r = ptr[0]*ptr[0] + ptr[1]*ptr[1];
372 r = ptr[0]*ptr[0] + ptr[1]*ptr[1] + ptr[2]*ptr[2];
375 if(rangeMin > 0.0
f && r < rangeMinSqrd)
379 if(rangeMax > 0.0
f && r > rangeMaxSqrd)
389 return LaserScan(cv::Mat(output,
cv::Range::all(), cv::Range(0, oi)), scan.
format(), scan.
rangeMin(), scan.
rangeMax(), scan.
angleMin(), scan.
angleMax(), scan.
angleIncrement(), scan.
localTransform());
411 cv::Mat output = cv::Mat(1, finalSize, scan.
dataType());
425 template<
typename Po
intT>
427 const typename pcl::PointCloud<PointT>::Ptr & cloud,
431 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
432 if(
step <= 1 || (
int)cloud->size() <=
step)
439 if(cloud->height > 1 && cloud->height < cloud->width/4)
449 unsigned int rings = cloud->height<cloud->width?cloud->height:cloud->width;
450 unsigned int pts = cloud->height>cloud->width?cloud->height:cloud->width;
451 unsigned int finalSize = rings * pts/
step;
452 output->resize(finalSize);
453 output->width = rings;
454 output->height = pts/
step;
456 for(
unsigned int j=0;
j<rings; ++
j)
458 for(
unsigned int i=0;
i<output->height; ++
i)
460 (*output)[
i*rings +
j] = cloud->at(
i*
step*rings +
j);
465 else if(cloud->height > 1)
469 uFormat(
"Decimation of depth images should be exact! (decimation=%d, size=%dx%d)",
470 step, cloud->width, cloud->height).c_str());
472 int finalSize = cloud->height/
step * cloud->width/
step;
473 output->resize(finalSize);
474 output->width = cloud->width/
step;
475 output->height = cloud->height/
step;
477 for(
unsigned int j=0;
j<output->height; ++
j)
479 for(
unsigned int i=0;
i<output->width; ++
i)
481 output->at(
j*output->width +
i) = cloud->at(
j*output->width*
step +
i*
step);
487 int finalSize =
int(cloud->size())/
step;
488 output->resize(finalSize);
490 for(
unsigned int i=0;
i<cloud->size()-
step+1;
i+=
step)
492 (*output)[oi++] = cloud->at(
i);
498 pcl::PointCloud<pcl::PointXYZ>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
int step)
500 return downsampleImpl<pcl::PointXYZ>(cloud,
step);
502 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
int step)
504 return downsampleImpl<pcl::PointXYZRGB>(cloud,
step);
506 pcl::PointCloud<pcl::PointXYZI>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
int step)
508 return downsampleImpl<pcl::PointXYZI>(cloud,
step);
510 pcl::PointCloud<pcl::PointNormal>::Ptr
downsample(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
int step)
512 return downsampleImpl<pcl::PointNormal>(cloud,
step);
514 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
int step)
516 return downsampleImpl<pcl::PointXYZRGBNormal>(cloud,
step);
518 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
int step)
520 return downsampleImpl<pcl::PointXYZINormal>(cloud,
step);
523 template<
typename Po
intT>
525 const typename pcl::PointCloud<PointT>::Ptr & cloud,
526 const pcl::IndicesPtr & indices,
531 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
532 if((cloud->is_dense && cloud->size()) || (!cloud->is_dense && !
indices->empty()))
534 Eigen::Vector4f min_p, max_p;
537 pcl::getMinMax3D<PointT>(*cloud, min_p, max_p);
539 pcl::getMinMax3D<PointT>(*cloud, *
indices, min_p, max_p);
542 float inverseVoxelSize = 1.0f/voxelSize;
549 UWARN(
"Leaf size is too small for the input dataset. Integer indices would overflow. "
550 "We will split space to be able to voxelize (lvl=%d cloud=%d min=[%f %f %f] max=[%f %f %f] voxel=%f).",
553 min_p[0], min_p[1], min_p[2],
554 max_p[0], max_p[1], max_p[2],
556 pcl::IndicesPtr denseIndices;
559 denseIndices.reset(
new std::vector<int>(cloud->size()));
560 for(
size_t i=0;
i<cloud->size(); ++
i)
562 denseIndices->at(
i) =
i;
566 Eigen::Vector4f mid = (max_p-min_p)/2.0
f;
567 int zMax = max_p[2]-min_p[2] < 10?1:2;
568 for(
int x=0;
x<2; ++
x)
570 for(
int y=0;
y<2; ++
y)
572 for(
int z=0;
z<zMax; ++
z)
574 Eigen::Vector4f
m = min_p+Eigen::Vector4f(mid[0]*
x,mid[1]*
y,mid[2]*
z,0);
575 Eigen::Vector4f mx =
m+mid;
584 *output+=*voxelizeImpl<PointT>(cloud,
ind, voxelSize,
level+1);
592 pcl::VoxelGrid<PointT> filter;
593 filter.setLeafSize(voxelSize, voxelSize, voxelSize);
594 filter.setInputCloud(cloud);
597 output->resize(cloud->size());
603 filter.filter(*output);
606 else if(cloud->size() && !cloud->is_dense &&
indices->size() == 0)
608 UWARN(
"Cannot voxelize a not dense (organized) cloud with empty indices! (input=%d pts). Returning empty cloud!", (
int)cloud->size());
613 pcl::PointCloud<pcl::PointXYZ>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
615 return voxelizeImpl<pcl::PointXYZ>(cloud,
indices, voxelSize);
617 pcl::PointCloud<pcl::PointNormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
619 return voxelizeImpl<pcl::PointNormal>(cloud,
indices, voxelSize);
621 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
623 return voxelizeImpl<pcl::PointXYZRGB>(cloud,
indices, voxelSize);
625 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
627 return voxelizeImpl<pcl::PointXYZRGBNormal>(cloud,
indices, voxelSize);
629 pcl::PointCloud<pcl::PointXYZI>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
631 return voxelizeImpl<pcl::PointXYZI>(cloud,
indices, voxelSize);
633 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
635 return voxelizeImpl<pcl::PointXYZINormal>(cloud,
indices, voxelSize);
638 pcl::PointCloud<pcl::PointXYZ>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
float voxelSize)
640 pcl::IndicesPtr
indices(
new std::vector<int>);
643 pcl::PointCloud<pcl::PointNormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
float voxelSize)
645 pcl::IndicesPtr
indices(
new std::vector<int>);
648 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
float voxelSize)
650 pcl::IndicesPtr
indices(
new std::vector<int>);
653 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
float voxelSize)
655 pcl::IndicesPtr
indices(
new std::vector<int>);
658 pcl::PointCloud<pcl::PointXYZI>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
float voxelSize)
660 pcl::IndicesPtr
indices(
new std::vector<int>);
663 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
float voxelSize)
665 pcl::IndicesPtr
indices(
new std::vector<int>);
669 template<
typename Po
intT>
671 const typename pcl::PointCloud<PointT>::Ptr & cloud,
int samples)
674 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
675 pcl::RandomSample<PointT> filter;
677 filter.setSeed (std::rand ());
678 filter.setInputCloud(cloud);
679 filter.filter(*output);
682 pcl::PointCloud<pcl::PointXYZ>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
int samples)
684 return randomSamplingImpl<pcl::PointXYZ>(cloud,
samples);
686 pcl::PointCloud<pcl::PointNormal>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
int samples)
688 return randomSamplingImpl<pcl::PointNormal>(cloud,
samples);
690 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
int samples)
692 return randomSamplingImpl<pcl::PointXYZRGB>(cloud,
samples);
694 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
int samples)
696 return randomSamplingImpl<pcl::PointXYZRGBNormal>(cloud,
samples);
698 pcl::PointCloud<pcl::PointXYZI>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
int samples)
700 return randomSamplingImpl<pcl::PointXYZI>(cloud,
samples);
702 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
int samples)
704 return randomSamplingImpl<pcl::PointXYZINormal>(cloud,
samples);
707 template<
typename Po
intT>
709 const typename pcl::PointCloud<PointT>::Ptr & cloud,
710 const pcl::IndicesPtr & indices,
711 const std::string &
axis,
719 pcl::IndicesPtr output(
new std::vector<int>);
720 pcl::PassThrough<PointT> filter;
721 filter.setNegative(negative);
722 filter.setFilterFieldName(
axis);
723 filter.setFilterLimits(
min,
max);
724 filter.setInputCloud(cloud);
726 filter.filter(*output);
730 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
734 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
736 return passThroughImpl<pcl::PointXYZRGB>(cloud,
indices,
axis,
min,
max, negative);
738 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
740 return passThroughImpl<pcl::PointXYZI>(cloud,
indices,
axis,
min,
max, negative);
742 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
744 return passThroughImpl<pcl::PointNormal>(cloud,
indices,
axis,
min,
max, negative);
746 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
748 return passThroughImpl<pcl::PointXYZRGBNormal>(cloud,
indices,
axis,
min,
max, negative);
750 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
752 return passThroughImpl<pcl::PointXYZINormal>(cloud,
indices,
axis,
min,
max, negative);
755 template<
typename Po
intT>
757 const typename pcl::PointCloud<PointT>::Ptr & cloud,
758 const std::string &
axis,
766 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
767 pcl::PassThrough<PointT> filter;
768 filter.setNegative(negative);
769 filter.setFilterFieldName(
axis);
770 filter.setFilterLimits(
min,
max);
771 filter.setInputCloud(cloud);
772 filter.filter(*output);
775 pcl::PointCloud<pcl::PointXYZ>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
777 return passThroughImpl<pcl::PointXYZ>(cloud,
axis,
min ,
max, negative);
779 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
781 return passThroughImpl<pcl::PointXYZRGB>(cloud,
axis,
min ,
max, negative);
783 pcl::PointCloud<pcl::PointXYZI>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
785 return passThroughImpl<pcl::PointXYZI>(cloud,
axis,
min ,
max, negative);
787 pcl::PointCloud<pcl::PointNormal>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
789 return passThroughImpl<pcl::PointNormal>(cloud,
axis,
min ,
max, negative);
791 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
793 return passThroughImpl<pcl::PointXYZRGBNormal>(cloud,
axis,
min ,
max, negative);
795 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
797 return passThroughImpl<pcl::PointXYZINormal>(cloud,
axis,
min ,
max, negative);
800 template<
typename Po
intT>
802 const typename pcl::PointCloud<PointT>::Ptr & cloud,
803 const pcl::IndicesPtr & indices,
804 const Eigen::Vector4f &
min,
805 const Eigen::Vector4f &
max,
811 pcl::IndicesPtr output(
new std::vector<int>);
812 pcl::CropBox<PointT> filter;
813 filter.setNegative(negative);
818 filter.setTransform(
transform.toEigen3f());
820 filter.setInputCloud(cloud);
822 filter.filter(*output);
826 pcl::IndicesPtr
cropBox(
const pcl::PCLPointCloud2::Ptr & cloud,
const pcl::IndicesPtr & indices,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
830 pcl::IndicesPtr output(
new std::vector<int>);
831 pcl::CropBox<pcl::PCLPointCloud2> filter;
832 filter.setNegative(negative);
837 filter.setTransform(
transform.toEigen3f());
839 filter.setInputCloud(cloud);
841 filter.filter(*output);
844 pcl::IndicesPtr
cropBox(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
848 pcl::IndicesPtr
cropBox(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
852 pcl::IndicesPtr
cropBox(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
856 pcl::IndicesPtr
cropBox(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
860 pcl::IndicesPtr
cropBox(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
864 pcl::IndicesPtr
cropBox(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
869 template<
typename Po
intT>
871 const typename pcl::PointCloud<PointT>::Ptr & cloud,
872 const Eigen::Vector4f &
min,
873 const Eigen::Vector4f &
max,
879 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
880 pcl::CropBox<PointT> filter;
881 filter.setNegative(negative);
886 filter.setTransform(
transform.toEigen3f());
888 filter.setInputCloud(cloud);
889 filter.filter(*output);
892 pcl::PointCloud<pcl::PointXYZ>::Ptr
cropBox(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
894 return cropBoxImpl<pcl::PointXYZ>(cloud,
min,
max,
transform, negative);
896 pcl::PointCloud<pcl::PointNormal>::Ptr
cropBox(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
898 return cropBoxImpl<pcl::PointNormal>(cloud,
min,
max,
transform, negative);
900 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
cropBox(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
902 return cropBoxImpl<pcl::PointXYZRGB>(cloud,
min,
max,
transform, negative);
904 pcl::PointCloud<pcl::PointXYZI>::Ptr
cropBox(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
906 return cropBoxImpl<pcl::PointXYZI>(cloud,
min,
max,
transform, negative);
908 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
cropBox(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
910 return cropBoxImpl<pcl::PointXYZINormal>(cloud,
min,
max,
transform, negative);
912 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
cropBox(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const Eigen::Vector4f &
min,
const Eigen::Vector4f &
max,
const Transform & transform,
bool negative)
914 return cropBoxImpl<pcl::PointXYZRGBNormal>(cloud,
min,
max,
transform, negative);
917 template<
typename Po
intT>
919 const typename pcl::PointCloud<PointT>::Ptr & cloud,
920 const pcl::IndicesPtr & indices,
924 float nearClipPlaneDistance,
925 float farClipPlaneDistance,
928 UASSERT(horizontalFOV > 0.0
f && verticalFOV > 0.0
f);
929 UASSERT(farClipPlaneDistance > nearClipPlaneDistance);
932 pcl::IndicesPtr output(
new std::vector<int>);
933 pcl::FrustumCulling<PointT> fc;
934 fc.setNegative(negative);
935 fc.setInputCloud (cloud);
940 fc.setVerticalFOV (verticalFOV);
941 fc.setHorizontalFOV (horizontalFOV);
942 fc.setNearPlaneDistance (nearClipPlaneDistance);
943 fc.setFarPlaneDistance (farClipPlaneDistance);
945 fc.setCameraPose (cameraPose.
toEigen4f());
950 pcl::IndicesPtr
frustumFiltering(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const Transform & cameraPose,
float horizontalFOV,
float verticalFOV,
float nearClipPlaneDistance,
float farClipPlaneDistance,
bool negative)
952 return frustumFilteringImpl<pcl::PointXYZ>(cloud,
indices, cameraPose, horizontalFOV, verticalFOV, nearClipPlaneDistance, farClipPlaneDistance, negative);
955 template<
typename Po
intT>
957 const typename pcl::PointCloud<PointT>::Ptr & cloud,
961 float nearClipPlaneDistance,
962 float farClipPlaneDistance,
965 UASSERT(horizontalFOV > 0.0
f && verticalFOV > 0.0
f);
966 UASSERT(farClipPlaneDistance > nearClipPlaneDistance);
969 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
970 pcl::FrustumCulling<PointT> fc;
971 fc.setNegative(negative);
972 fc.setInputCloud (cloud);
973 fc.setVerticalFOV (verticalFOV);
974 fc.setHorizontalFOV (horizontalFOV);
975 fc.setNearPlaneDistance (nearClipPlaneDistance);
976 fc.setFarPlaneDistance (farClipPlaneDistance);
978 fc.setCameraPose (cameraPose.
toEigen4f());
983 pcl::PointCloud<pcl::PointXYZ>::Ptr
frustumFiltering(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const Transform & cameraPose,
float horizontalFOV,
float verticalFOV,
float nearClipPlaneDistance,
float farClipPlaneDistance,
bool negative)
985 return frustumFilteringImpl<pcl::PointXYZ>(cloud, cameraPose, horizontalFOV, verticalFOV, nearClipPlaneDistance, farClipPlaneDistance, negative);
987 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
frustumFiltering(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const Transform & cameraPose,
float horizontalFOV,
float verticalFOV,
float nearClipPlaneDistance,
float farClipPlaneDistance,
bool negative)
989 return frustumFilteringImpl<pcl::PointXYZRGB>(cloud, cameraPose, horizontalFOV, verticalFOV, nearClipPlaneDistance, farClipPlaneDistance, negative);
993 template<
typename Po
intT>
995 const typename pcl::PointCloud<PointT>::Ptr & cloud)
997 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
1004 return removeNaNFromPointCloudImpl<pcl::PointXYZ>(cloud);
1008 return removeNaNFromPointCloudImpl<pcl::PointXYZRGB>(cloud);
1012 return removeNaNFromPointCloudImpl<pcl::PointXYZI>(cloud);
1017 pcl::PCLPointCloud2::Ptr output(
new pcl::PCLPointCloud2);
1018 output->fields = cloud->fields;
1019 output->header = cloud->header;
1021 output->point_step = cloud->point_step;
1022 output->is_dense =
true;
1023 output->data.resize(cloud->row_step*cloud->height);
1026 for(
size_t i=0;
i<cloud->fields.size(); ++
i)
1028 if(cloud->fields[
i].name.compare(
"z") == 0)
1038 for (
size_t row = 0;
row < cloud->height; ++
row)
1041 for (
size_t col = 0;
col < cloud->width; ++
col)
1044 const float *
x = (
const float*)&msg_data[0];
1045 const float *
y = (
const float*)&msg_data[4];
1046 const float *
z = (
const float*)&msg_data[is3D?8:4];
1049 memcpy (output_data, msg_data, cloud->point_step);
1050 output_data += cloud->point_step;
1056 output->row_step = output->width*output->point_step;
1057 output->data.resize(output->row_step);
1061 template<
typename Po
intT>
1063 const typename pcl::PointCloud<PointT>::Ptr & cloud)
1065 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
1071 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud)
1073 return removeNaNNormalsFromPointCloudImpl<pcl::PointNormal>(cloud);
1076 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud)
1078 return removeNaNNormalsFromPointCloudImpl<pcl::PointXYZRGBNormal>(cloud);
1081 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud)
1083 return removeNaNNormalsFromPointCloudImpl<pcl::PointXYZINormal>(cloud);
1087 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1089 pcl::IndicesPtr
indices(
new std::vector<int>);
1092 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1094 pcl::IndicesPtr
indices(
new std::vector<int>);
1097 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1099 pcl::IndicesPtr
indices(
new std::vector<int>);
1102 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1104 pcl::IndicesPtr
indices(
new std::vector<int>);
1107 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1109 pcl::IndicesPtr
indices(
new std::vector<int>);
1112 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1114 pcl::IndicesPtr
indices(
new std::vector<int>);
1118 template<
typename Po
intT>
1120 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1121 const pcl::IndicesPtr & indices,
1123 int minNeighborsInRadius)
1125 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
false));
1129 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1132 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1135 std::vector<float> kDistances;
1136 int k =
tree->radiusSearch(cloud->at(
indices->at(
i)), radiusSearch,
kIndices, kDistances, minNeighborsInRadius+1);
1137 if(k > minNeighborsInRadius)
1147 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1149 tree->setInputCloud(cloud);
1150 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1153 std::vector<float> kDistances;
1154 int k =
tree->radiusSearch(cloud->at(
i), radiusSearch,
kIndices, kDistances, minNeighborsInRadius+1);
1155 if(k > minNeighborsInRadius)
1157 output->at(oi++) =
i;
1165 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1167 return radiusFilteringImpl<pcl::PointXYZ>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1169 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1171 return radiusFilteringImpl<pcl::PointNormal>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1173 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1175 return radiusFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1177 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1179 return radiusFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1181 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1183 return radiusFilteringImpl<pcl::PointXYZI>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1185 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1187 return radiusFilteringImpl<pcl::PointXYZINormal>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1191 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
1192 const std::vector<int> & viewpointIndices,
1193 const std::map<int, Transform> & viewpoints,
1195 float neighborScale)
1197 pcl::IndicesPtr
indices(
new std::vector<int>);
1201 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
1202 const std::vector<int> & viewpointIndices,
1203 const std::map<int, Transform> & viewpoints,
1205 float neighborScale)
1207 pcl::IndicesPtr
indices(
new std::vector<int>);
1211 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1212 const std::vector<int> & viewpointIndices,
1213 const std::map<int, Transform> & viewpoints,
1215 float neighborScale)
1217 pcl::IndicesPtr
indices(
new std::vector<int>);
1221 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1222 const std::vector<int> & viewpointIndices,
1223 const std::map<int, Transform> & viewpoints,
1225 float neighborScale)
1227 pcl::IndicesPtr
indices(
new std::vector<int>);
1231 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
1232 const std::vector<int> & viewpointIndices,
1233 const std::map<int, Transform> & viewpoints,
1235 float neighborScale)
1237 pcl::IndicesPtr
indices(
new std::vector<int>);
1241 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
1242 const std::vector<int> & viewpointIndices,
1243 const std::map<int, Transform> & viewpoints,
1245 float neighborScale)
1247 pcl::IndicesPtr
indices(
new std::vector<int>);
1251 template<
typename Po
intT>
1253 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1254 const pcl::IndicesPtr & indices,
1255 const std::vector<int> & viewpointIndices,
1256 const std::map<int, Transform> & viewpoints,
1258 float neighborScale)
1260 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
false));
1262 UASSERT(cloud->size() == viewpointIndices.size());
1268 std::vector<bool> kept(
indices->size());
1274 std::vector<float> kDistances;
1275 std::map<int, Transform>::const_iterator viewpointIter = viewpoints.find(viewpointIndices[index]);
1276 UASSERT(viewpointIter != viewpoints.end());
1277 cv::Point3f viewpoint(viewpointIter->second.x(), viewpointIter->second.y(), viewpointIter->second.z());
1278 cv::Point3f
point = cv::Point3f(cloud->at(index).x,cloud->at(index).y, cloud->at(index).z);
1279 float radiusSearch = factor * cv::norm(viewpoint-
point);
1280 int k =
tree->radiusSearch(cloud->at(index), radiusSearch,
kIndices, kDistances);
1282 for(
int j=0;
j<k && keep; ++
j)
1287 cv::Point3f tmp = pointTmp -
point;
1288 float distPtSqr = tmp.dot(tmp);
1289 viewpointIter = viewpoints.find(viewpointIndices[
kIndices[
j]]);
1290 UASSERT(viewpointIter != viewpoints.end());
1291 viewpoint = cv::Point3f(viewpointIter->second.x(), viewpointIter->second.y(), viewpointIter->second.z());
1292 float radiusSearchTmp = factor * cv::norm(viewpoint-pointTmp) * neighborScale;
1293 if(distPtSqr > radiusSearchTmp*radiusSearchTmp)
1301 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1315 std::vector<bool> kept(cloud->size());
1316 tree->setInputCloud(cloud);
1317 #pragma omp parallel for
1318 for(
int i=0;
i<(
int)cloud->size(); ++
i)
1321 std::vector<float> kDistances;
1322 std::map<int, Transform>::const_iterator viewpointIter = viewpoints.find(viewpointIndices[
i]);
1323 UASSERT(viewpointIter != viewpoints.end());
1324 cv::Point3f viewpoint(viewpointIter->second.x(), viewpointIter->second.y(), viewpointIter->second.z());
1325 cv::Point3f
point = cv::Point3f(cloud->at(
i).x,cloud->at(
i).y, cloud->at(
i).z);
1326 float radiusSearch = factor * cv::norm(viewpoint-
point);
1327 int k =
tree->radiusSearch(cloud->at(
i), radiusSearch,
kIndices, kDistances);
1329 for(
int j=0;
j<k && keep; ++
j)
1334 cv::Point3f tmp = pointTmp -
point;
1335 float distPtSqr = tmp.dot(tmp);
1336 viewpointIter = viewpoints.find(viewpointIndices[
kIndices[
j]]);
1337 UASSERT(viewpointIter != viewpoints.end());
1338 viewpoint = cv::Point3f(viewpointIter->second.x(), viewpointIter->second.y(), viewpointIter->second.z());
1339 float radiusSearchTmp = factor * cv::norm(viewpoint-pointTmp) * neighborScale;
1340 if(distPtSqr > radiusSearchTmp*radiusSearchTmp)
1348 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1350 for(
size_t i=0;
i<cloud->size(); ++
i)
1354 output->at(oi++) =
i;
1363 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
1364 const pcl::IndicesPtr & indices,
1365 const std::vector<int> & viewpointIndices,
1366 const std::map<int, Transform> & viewpoints,
1368 float neighborScale)
1370 return proportionalRadiusFilteringImpl<pcl::PointXYZ>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1373 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
1374 const pcl::IndicesPtr & indices,
1375 const std::vector<int> & viewpointIndices,
1376 const std::map<int, Transform> & viewpoints,
1378 float neighborScale)
1380 return proportionalRadiusFilteringImpl<pcl::PointNormal>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1383 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1384 const pcl::IndicesPtr & indices,
1385 const std::vector<int> & viewpointIndices,
1386 const std::map<int, Transform> & viewpoints,
1388 float neighborScale)
1390 return proportionalRadiusFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1393 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1394 const pcl::IndicesPtr & indices,
1395 const std::vector<int> & viewpointIndices,
1396 const std::map<int, Transform> & viewpoints,
1398 float neighborScale)
1400 return proportionalRadiusFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1403 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
1404 const pcl::IndicesPtr & indices,
1405 const std::vector<int> & viewpointIndices,
1406 const std::map<int, Transform> & viewpoints,
1408 float neighborScale)
1410 return proportionalRadiusFilteringImpl<pcl::PointXYZI>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1413 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
1414 const pcl::IndicesPtr & indices,
1415 const std::vector<int> & viewpointIndices,
1416 const std::map<int, Transform> & viewpoints,
1418 float neighborScale)
1420 return proportionalRadiusFilteringImpl<pcl::PointXYZINormal>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1424 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1425 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & substractCloud,
1427 int minNeighborsInRadius)
1429 pcl::IndicesPtr
indices(
new std::vector<int>);
1431 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
out(
new pcl::PointCloud<pcl::PointXYZRGB>);
1432 pcl::copyPointCloud(*cloud, *indicesOut, *
out);
1436 template<
typename Po
intT>
1438 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1439 const pcl::IndicesPtr & indices,
1440 const typename pcl::PointCloud<PointT>::Ptr & substractCloud,
1441 const pcl::IndicesPtr & substractIndices,
1443 int minNeighborsInRadius)
1445 UASSERT(minNeighborsInRadius > 0);
1446 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
false));
1450 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1452 if(substractIndices->size())
1454 tree->setInputCloud(substractCloud, substractIndices);
1458 tree->setInputCloud(substractCloud);
1460 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1463 std::vector<float> kDistances;
1465 if(k < minNeighborsInRadius)
1475 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1477 if(substractIndices->size())
1479 tree->setInputCloud(substractCloud, substractIndices);
1483 tree->setInputCloud(substractCloud);
1485 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1488 std::vector<float> kDistances;
1489 int k =
tree->radiusSearch(cloud->at(
i), radiusSearch,
kIndices, kDistances);
1490 if(k < minNeighborsInRadius)
1492 output->at(oi++) =
i;
1500 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1501 const pcl::IndicesPtr & indices,
1502 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & substractCloud,
1503 const pcl::IndicesPtr & substractIndices,
1505 int minNeighborsInRadius)
1507 return subtractFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, substractCloud, substractIndices, radiusSearch, minNeighborsInRadius);
1511 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
1512 const pcl::PointCloud<pcl::PointNormal>::Ptr & substractCloud,
1515 int minNeighborsInRadius)
1517 pcl::IndicesPtr
indices(
new std::vector<int>);
1519 pcl::PointCloud<pcl::PointNormal>::Ptr
out(
new pcl::PointCloud<pcl::PointNormal>);
1520 pcl::copyPointCloud(*cloud, *indicesOut, *
out);
1524 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
1525 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & substractCloud,
1528 int minNeighborsInRadius)
1530 pcl::IndicesPtr
indices(
new std::vector<int>);
1532 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
out(
new pcl::PointCloud<pcl::PointXYZINormal>);
1533 pcl::copyPointCloud(*cloud, *indicesOut, *
out);
1537 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1538 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & substractCloud,
1541 int minNeighborsInRadius)
1543 pcl::IndicesPtr
indices(
new std::vector<int>);
1545 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
out(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
1546 pcl::copyPointCloud(*cloud, *indicesOut, *
out);
1550 template<
typename Po
intT>
1552 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1553 const pcl::IndicesPtr & indices,
1554 const typename pcl::PointCloud<PointT>::Ptr & substractCloud,
1555 const pcl::IndicesPtr & substractIndices,
1558 int minNeighborsInRadius)
1560 UASSERT(minNeighborsInRadius > 0);
1561 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
false));
1565 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1567 if(substractIndices->size())
1569 tree->setInputCloud(substractCloud, substractIndices);
1573 tree->setInputCloud(substractCloud);
1575 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1578 std::vector<float> kDistances;
1580 if(k>=minNeighborsInRadius && maxAngle > 0.0
f)
1588 for(
int j=0; j<count && k >= minNeighborsInRadius; ++
j)
1590 Eigen::Vector4f
v(substractCloud->at(
kIndices.at(
j)).normal_x, substractCloud->at(
kIndices.at(
j)).normal_y, substractCloud->at(
kIndices.at(
j)).normal_z, 0.0f);
1596 if(
angle > maxAngle)
1612 if(k < minNeighborsInRadius)
1622 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1624 if(substractIndices->size())
1626 tree->setInputCloud(substractCloud, substractIndices);
1630 tree->setInputCloud(substractCloud);
1632 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1635 std::vector<float> kDistances;
1636 int k =
tree->radiusSearch(cloud->at(
i), radiusSearch,
kIndices, kDistances);
1637 if(k>=minNeighborsInRadius && maxAngle > 0.0
f)
1639 Eigen::Vector4f
normal(cloud->at(
i).normal_x, cloud->at(
i).normal_y, cloud->at(
i).normal_z, 0.0f);
1645 for(
int j=0; j<count && k >= minNeighborsInRadius; ++
j)
1647 Eigen::Vector4f
v(substractCloud->at(
kIndices.at(
j)).normal_x, substractCloud->at(
kIndices.at(
j)).normal_y, substractCloud->at(
kIndices.at(
j)).normal_z, 0.0f);
1653 if(
angle > maxAngle)
1669 if(k < minNeighborsInRadius)
1671 output->at(oi++) =
i;
1680 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
1681 const pcl::IndicesPtr & indices,
1682 const pcl::PointCloud<pcl::PointNormal>::Ptr & substractCloud,
1683 const pcl::IndicesPtr & substractIndices,
1686 int minNeighborsInRadius)
1688 return subtractFilteringImpl<pcl::PointNormal>(cloud,
indices, substractCloud, substractIndices, radiusSearch, maxAngle, minNeighborsInRadius);
1691 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
1692 const pcl::IndicesPtr & indices,
1693 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & substractCloud,
1694 const pcl::IndicesPtr & substractIndices,
1697 int minNeighborsInRadius)
1699 return subtractFilteringImpl<pcl::PointXYZINormal>(cloud,
indices, substractCloud, substractIndices, radiusSearch, maxAngle, minNeighborsInRadius);
1702 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1703 const pcl::IndicesPtr & indices,
1704 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & substractCloud,
1705 const pcl::IndicesPtr & substractIndices,
1708 int minNeighborsInRadius)
1710 return subtractFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, substractCloud, substractIndices, radiusSearch, maxAngle, minNeighborsInRadius);
1714 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1715 const pcl::IndicesPtr & indices,
1716 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & substractCloud,
1717 const pcl::IndicesPtr & substractIndices,
1718 float radiusSearchRatio,
1719 int minNeighborsInRadius,
1720 const Eigen::Vector3f & viewpoint)
1722 UWARN(
"Add angle to avoid subtraction of points with opposite normals");
1723 UASSERT(minNeighborsInRadius > 0);
1725 pcl::search::KdTree<pcl::PointXYZRGB>::Ptr
tree (
new pcl::search::KdTree<pcl::PointXYZRGB>(
false));
1729 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1731 if(substractIndices->size())
1733 tree->setInputCloud(substractCloud, substractIndices);
1737 tree->setInputCloud(substractCloud);
1739 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1741 if(pcl::isFinite(cloud->at(
indices->at(
i))))
1744 std::vector<float> kSqrdDistances;
1745 float radius = radiusSearchRatio*
uNorm(
1746 cloud->at(
indices->at(
i)).x-viewpoint[0],
1747 cloud->at(
indices->at(
i)).y-viewpoint[1],
1748 cloud->at(
indices->at(
i)).z-viewpoint[2]);
1750 if(k < minNeighborsInRadius)
1761 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1763 if(substractIndices->size())
1765 tree->setInputCloud(substractCloud, substractIndices);
1769 tree->setInputCloud(substractCloud);
1771 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1773 if(pcl::isFinite(cloud->at(
i)))
1776 std::vector<float> kSqrdDistances;
1777 float radius = radiusSearchRatio*
uNorm(
1778 cloud->at(
i).x-viewpoint[0],
1779 cloud->at(
i).y-viewpoint[1],
1780 cloud->at(
i).z-viewpoint[2]);
1781 int k =
tree->radiusSearch(cloud->at(
i), radius,
kIndices, kSqrdDistances);
1782 if(k < minNeighborsInRadius)
1784 output->at(oi++) =
i;
1793 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1794 const pcl::IndicesPtr & indices,
1795 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & substractCloud,
1796 const pcl::IndicesPtr & substractIndices,
1797 float radiusSearchRatio,
1799 int minNeighborsInRadius,
1800 const Eigen::Vector3f & viewpoint)
1802 UASSERT(minNeighborsInRadius > 0);
1804 pcl::search::KdTree<pcl::PointXYZRGBNormal>::Ptr
tree (
new pcl::search::KdTree<pcl::PointXYZRGBNormal>(
false));
1808 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1810 if(substractIndices->size())
1812 tree->setInputCloud(substractCloud, substractIndices);
1816 tree->setInputCloud(substractCloud);
1818 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1820 if(pcl::isFinite(cloud->at(
indices->at(
i))))
1823 std::vector<float> kSqrdDistances;
1824 float radius = radiusSearchRatio*
uNorm(
1825 cloud->at(
indices->at(
i)).x-viewpoint[0],
1826 cloud->at(
indices->at(
i)).y-viewpoint[1],
1827 cloud->at(
indices->at(
i)).z-viewpoint[2]);
1829 if(k>=minNeighborsInRadius && maxAngle > 0.0
f)
1837 for(
int j=0; j<count && k >= minNeighborsInRadius; ++
j)
1839 Eigen::Vector4f
v(substractCloud->at(
kIndices.at(
j)).normal_x, substractCloud->at(
kIndices.at(
j)).normal_y, substractCloud->at(
kIndices.at(
j)).normal_z, 0.0f);
1845 if(
angle > maxAngle)
1862 if(k < minNeighborsInRadius)
1873 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1875 if(substractIndices->size())
1877 tree->setInputCloud(substractCloud, substractIndices);
1881 tree->setInputCloud(substractCloud);
1883 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1885 if(pcl::isFinite(cloud->at(
i)))
1888 std::vector<float> kSqrdDistances;
1889 float radius = radiusSearchRatio*
uNorm(
1890 cloud->at(
i).x-viewpoint[0],
1891 cloud->at(
i).y-viewpoint[1],
1892 cloud->at(
i).z-viewpoint[2]);
1893 int k =
tree->radiusSearch(cloud->at(
i), radius,
kIndices, kSqrdDistances);
1894 if(k>=minNeighborsInRadius && maxAngle > 0.0
f)
1896 Eigen::Vector4f
normal(cloud->at(
i).normal_x, cloud->at(
i).normal_y, cloud->at(
i).normal_z, 0.0f);
1902 for(
int j=0; j<count && k >= minNeighborsInRadius; ++
j)
1904 Eigen::Vector4f
v(substractCloud->at(
kIndices.at(
j)).normal_x, substractCloud->at(
kIndices.at(
j)).normal_y, substractCloud->at(
kIndices.at(
j)).normal_z, 0.0f);
1910 if(
angle > maxAngle)
1926 if(k < minNeighborsInRadius)
1928 output->at(oi++) =
i;
1939 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
1941 const Eigen::Vector4f & normal,
1943 const Eigen::Vector4f & viewpoint,
1944 float groundNormalsUp)
1946 pcl::IndicesPtr
indices(
new std::vector<int>);
1950 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1952 const Eigen::Vector4f & normal,
1954 const Eigen::Vector4f & viewpoint,
1955 float groundNormalsUp)
1957 pcl::IndicesPtr
indices(
new std::vector<int>);
1962 template<
typename Po
intT>
1964 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1965 const pcl::IndicesPtr & indices,
1967 const Eigen::Vector4f & normal,
1969 const Eigen::Vector4f & viewpoint,
1970 float groundNormalsUp)
1972 pcl::IndicesPtr output(
new std::vector<int>());
1976 typename pcl::search::KdTree<PointT>::Ptr
tree(
new pcl::search::KdTree<PointT>(
false));
1978 pcl::NormalEstimationOMP<PointT, pcl::Normal> ne;
1979 ne.setInputCloud (cloud);
1991 tree->setInputCloud(cloud);
1993 ne.setSearchMethod (
tree);
1995 pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (
new pcl::PointCloud<pcl::Normal>);
1997 ne.setKSearch(normalKSearch);
1998 if(viewpoint[0] != 0 || viewpoint[1] != 0 || viewpoint[2] != 0)
2000 ne.setViewPoint(viewpoint[0], viewpoint[1], viewpoint[2]);
2003 ne.compute (*cloud_normals);
2005 output->resize(cloud_normals->size());
2007 for(
unsigned int i=0;
i<cloud_normals->size(); ++
i)
2009 Eigen::Vector4f
v(cloud_normals->at(
i).normal_x, cloud_normals->at(
i).normal_y, cloud_normals->at(
i).normal_z, 0.0f);
2010 if(groundNormalsUp>0.0
f &&
v[2] < -groundNormalsUp && cloud->at(
indices->size()!=0?
indices->at(
i):
i).z < viewpoint[3])
2017 if(
angle < angleMax)
2028 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2029 const pcl::IndicesPtr & indices,
2031 const Eigen::Vector4f & normal,
2033 const Eigen::Vector4f & viewpoint,
2034 float groundNormalsUp)
2036 return normalFilteringImpl<pcl::PointXYZ>(cloud,
indices, angleMax,
normal, normalKSearch, viewpoint, groundNormalsUp);
2039 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
2040 const pcl::IndicesPtr & indices,
2042 const Eigen::Vector4f & normal,
2044 const Eigen::Vector4f & viewpoint,
2045 float groundNormalsUp)
2047 return normalFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, angleMax,
normal, normalKSearch, viewpoint, groundNormalsUp);
2050 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
2051 const pcl::IndicesPtr & indices,
2053 const Eigen::Vector4f & normal,
2055 const Eigen::Vector4f & viewpoint,
2056 float groundNormalsUp)
2058 return normalFilteringImpl<pcl::PointXYZI>(cloud,
indices, angleMax,
normal, normalKSearch, viewpoint, groundNormalsUp);
2061 template<
typename Po
intNormalT>
2063 const typename pcl::PointCloud<PointNormalT>::Ptr & cloud,
2064 const pcl::IndicesPtr & indices,
2066 const Eigen::Vector4f & normal,
2067 const Eigen::Vector4f & viewpoint,
2068 float groundNormalsUp)
2070 pcl::IndicesPtr output(
new std::vector<int>());
2077 output->resize(
indices->size());
2078 for(
unsigned int i=0;
i<
indices->size(); ++
i)
2080 Eigen::Vector4f
v(cloud->at(
indices->at(
i)).normal_x, cloud->at(
indices->at(
i)).normal_y, cloud->at(
indices->at(
i)).normal_z, 0.0f);
2081 if(groundNormalsUp>0.0
f &&
v[2] < -groundNormalsUp && cloud->at(
indices->at(
i)).z < viewpoint[3])
2087 if(
angle < angleMax)
2095 output->resize(cloud->size());
2096 for(
unsigned int i=0;
i<cloud->size(); ++
i)
2098 Eigen::Vector4f
v(cloud->at(
i).normal_x, cloud->at(
i).normal_y, cloud->at(
i).normal_z, 0.0f);
2099 if(groundNormalsUp>0.0
f &&
v[2] < -groundNormalsUp && cloud->at(
i).z < viewpoint[3])
2105 if(
angle < angleMax)
2118 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
2119 const pcl::IndicesPtr & indices,
2121 const Eigen::Vector4f & normal,
2123 const Eigen::Vector4f & viewpoint,
2124 float groundNormalsUp)
2126 return normalFilteringImpl<pcl::PointNormal>(cloud,
indices, angleMax,
normal, viewpoint, groundNormalsUp);
2129 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
2130 const pcl::IndicesPtr & indices,
2132 const Eigen::Vector4f & normal,
2134 const Eigen::Vector4f & viewpoint,
2135 float groundNormalsUp)
2137 return normalFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, angleMax,
normal, viewpoint, groundNormalsUp);
2140 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
2141 const pcl::IndicesPtr & indices,
2143 const Eigen::Vector4f & normal,
2145 const Eigen::Vector4f & viewpoint,
2146 float groundNormalsUp)
2148 return normalFilteringImpl<pcl::PointXYZINormal>(cloud,
indices, angleMax,
normal, viewpoint, groundNormalsUp);
2152 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2153 float clusterTolerance,
2156 int * biggestClusterIndex)
2158 pcl::IndicesPtr
indices(
new std::vector<int>);
2159 return extractClusters(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2162 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
2163 float clusterTolerance,
2166 int * biggestClusterIndex)
2168 pcl::IndicesPtr
indices(
new std::vector<int>);
2169 return extractClusters(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2172 template<
typename Po
intT>
2174 const typename pcl::PointCloud<PointT>::Ptr & cloud,
2175 const pcl::IndicesPtr & indices,
2176 float clusterTolerance,
2179 int * biggestClusterIndex)
2181 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
true));
2182 pcl::EuclideanClusterExtraction<PointT> ec;
2183 ec.setClusterTolerance (clusterTolerance);
2184 ec.setMinClusterSize (minClusterSize);
2185 ec.setMaxClusterSize (maxClusterSize);
2186 ec.setInputCloud (cloud);
2195 tree->setInputCloud(cloud);
2197 ec.setSearchMethod (
tree);
2199 std::vector<pcl::PointIndices> cluster_indices;
2200 ec.extract (cluster_indices);
2203 unsigned int maxSize = 0;
2204 std::vector<pcl::IndicesPtr> output(cluster_indices.size());
2205 for(
unsigned int i=0;
i<cluster_indices.size(); ++
i)
2207 output[
i] = pcl::IndicesPtr(
new std::vector<int>(cluster_indices[
i].
indices));
2209 if(maxSize < cluster_indices[
i].
indices.size())
2211 maxSize = (
unsigned int)cluster_indices[
i].
indices.size();
2215 if(biggestClusterIndex)
2217 *biggestClusterIndex = maxIndex;
2224 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2225 const pcl::IndicesPtr & indices,
2226 float clusterTolerance,
2229 int * biggestClusterIndex)
2231 return extractClustersImpl<pcl::PointXYZ>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2234 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
2235 const pcl::IndicesPtr & indices,
2236 float clusterTolerance,
2239 int * biggestClusterIndex)
2241 return extractClustersImpl<pcl::PointNormal>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2244 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
2245 const pcl::IndicesPtr & indices,
2246 float clusterTolerance,
2249 int * biggestClusterIndex)
2251 return extractClustersImpl<pcl::PointXYZRGB>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2254 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
2255 const pcl::IndicesPtr & indices,
2256 float clusterTolerance,
2259 int * biggestClusterIndex)
2261 return extractClustersImpl<pcl::PointXYZRGBNormal>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2264 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
2265 const pcl::IndicesPtr & indices,
2266 float clusterTolerance,
2269 int * biggestClusterIndex)
2271 return extractClustersImpl<pcl::PointXYZI>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2274 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
2275 const pcl::IndicesPtr & indices,
2276 float clusterTolerance,
2279 int * biggestClusterIndex)
2281 return extractClustersImpl<pcl::PointXYZINormal>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2284 template<
typename Po
intT>
2286 const typename pcl::PointCloud<PointT>::Ptr & cloud,
2287 const pcl::IndicesPtr & indices,
2290 pcl::IndicesPtr output(
new std::vector<int>);
2291 pcl::ExtractIndices<PointT>
extract;
2292 extract.setInputCloud (cloud);
2294 extract.setNegative(negative);
2299 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2301 return extractIndicesImpl<pcl::PointXYZ>(cloud,
indices, negative);
2303 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2305 return extractIndicesImpl<pcl::PointNormal>(cloud,
indices, negative);
2307 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2309 return extractIndicesImpl<pcl::PointXYZRGB>(cloud,
indices, negative);
2311 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2313 return extractIndicesImpl<pcl::PointXYZRGBNormal>(cloud,
indices, negative);
2315 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2317 return extractIndicesImpl<pcl::PointXYZI>(cloud,
indices, negative);
2319 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2321 return extractIndicesImpl<pcl::PointXYZINormal>(cloud,
indices, negative);
2324 template<
typename Po
intT>
2326 const typename pcl::PointCloud<PointT>::Ptr & cloud,
2327 const pcl::IndicesPtr & indices,
2331 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
2332 pcl::ExtractIndices<PointT>
extract;
2333 extract.setInputCloud (cloud);
2335 extract.setNegative(negative);
2336 extract.setKeepOrganized(keepOrganized);
2340 pcl::PointCloud<pcl::PointXYZ>::Ptr
extractIndices(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative,
bool keepOrganized)
2342 return extractIndicesImpl<pcl::PointXYZ>(cloud,
indices, negative, keepOrganized);
2344 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
extractIndices(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative,
bool keepOrganized)
2346 return extractIndicesImpl<pcl::PointXYZRGB>(cloud,
indices, negative, keepOrganized);
2353 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
extractIndices(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative,
bool keepOrganized)
2355 return extractIndicesImpl<pcl::PointXYZRGBNormal>(cloud,
indices, negative, keepOrganized);
2359 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2360 float distanceThreshold,
2362 pcl::ModelCoefficients * coefficientsOut)
2364 pcl::IndicesPtr
indices(
new std::vector<int>);
2369 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2370 const pcl::IndicesPtr & indices,
2371 float distanceThreshold,
2373 pcl::ModelCoefficients * coefficientsOut)
2376 pcl::ModelCoefficients::Ptr coefficients (
new pcl::ModelCoefficients);
2377 pcl::PointIndices::Ptr inliers (
new pcl::PointIndices);
2379 pcl::SACSegmentation<pcl::PointXYZ> seg;
2381 seg.setOptimizeCoefficients (
true);
2382 seg.setMaxIterations (maxIterations);
2384 seg.setModelType (pcl::SACMODEL_PLANE);
2385 seg.setMethodType (pcl::SAC_RANSAC);
2386 seg.setDistanceThreshold (distanceThreshold);
2388 seg.setInputCloud (cloud);
2393 seg.segment (*inliers, *coefficients);
2397 *coefficientsOut = *coefficients;
2400 return pcl::IndicesPtr(
new std::vector<int>(inliers->indices));