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());
398 template<
typename Po
intT>
400 const typename pcl::PointCloud<PointT>::Ptr & cloud,
401 const pcl::IndicesPtr & indices,
405 UASSERT(rangeMin >=0.0
f && rangeMax>=0.0
f);
407 pcl::IndicesPtr output(
new std::vector<int>());
408 output->reserve(
size);
411 if(rangeMin > 0.0
f || rangeMax > 0.0
f)
413 float rangeMinSqrd = rangeMin * rangeMin;
414 float rangeMaxSqrd = rangeMax * rangeMax;
418 const PointT & pt = cloud->at(index);
419 float r = pt.x*pt.x + pt.y*pt.y + pt.z*pt.z;
421 if(rangeMin > 0.0
f && r < rangeMinSqrd)
425 if(rangeMax > 0.0
f && r > rangeMaxSqrd)
430 output->push_back(index);
443 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
444 const pcl::IndicesPtr & indices,
448 return rangeFilteringImpl<pcl::PointXYZ>(cloud,
indices, rangeMin, rangeMax);
451 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
452 const pcl::IndicesPtr & indices,
456 return rangeFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, rangeMin, rangeMax);
459 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
460 const pcl::IndicesPtr & indices,
464 return rangeFilteringImpl<pcl::PointNormal>(cloud,
indices, rangeMin, rangeMax);
467 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
468 const pcl::IndicesPtr & indices,
472 return rangeFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, rangeMin, rangeMax);
475 template<
typename Po
intT>
477 const typename pcl::PointCloud<PointT>::Ptr & cloud,
478 const pcl::IndicesPtr & indices,
480 pcl::IndicesPtr & closeIndices,
481 pcl::IndicesPtr & farIndices)
484 closeIndices.reset(
new std::vector<int>());
485 farIndices.reset(
new std::vector<int>());
486 closeIndices->reserve(
size);
487 farIndices->reserve(
size);
494 const PointT & pt = cloud->at(index);
495 float r = pt.x*pt.x + pt.y*pt.y + pt.z*pt.z;
499 closeIndices->push_back(index);
503 farIndices->push_back(index);
510 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
511 const pcl::IndicesPtr & indices,
513 pcl::IndicesPtr & closeIndices,
514 pcl::IndicesPtr & farIndices)
516 rangeSplitFilteringImpl<pcl::PointXYZ>(cloud,
indices,
range, closeIndices, farIndices);
519 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
520 const pcl::IndicesPtr & indices,
522 pcl::IndicesPtr & closeIndices,
523 pcl::IndicesPtr & farIndices)
525 rangeSplitFilteringImpl<pcl::PointXYZRGB>(cloud,
indices,
range, closeIndices, farIndices);
528 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
529 const pcl::IndicesPtr & indices,
531 pcl::IndicesPtr & closeIndices,
532 pcl::IndicesPtr & farIndices)
534 rangeSplitFilteringImpl<pcl::PointNormal>(cloud,
indices,
range, closeIndices, farIndices);
537 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
538 const pcl::IndicesPtr & indices,
540 pcl::IndicesPtr & closeIndices,
541 pcl::IndicesPtr & farIndices)
543 rangeSplitFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices,
range, closeIndices, farIndices);
559 cv::Mat output = cv::Mat(1, finalSize, scan.
dataType());
573 template<
typename Po
intT>
575 const typename pcl::PointCloud<PointT>::Ptr & cloud,
579 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
580 if(
step <= 1 || (
int)cloud->size() <=
step)
587 if(cloud->height > 1 && cloud->height < cloud->width/4)
597 unsigned int rings = cloud->height<cloud->width?cloud->height:cloud->width;
598 unsigned int pts = cloud->height>cloud->width?cloud->height:cloud->width;
599 unsigned int finalSize = rings * pts/
step;
600 output->resize(finalSize);
601 output->width = rings;
602 output->height = pts/
step;
604 for(
unsigned int j=0;
j<rings; ++
j)
606 for(
unsigned int i=0;
i<output->height; ++
i)
608 (*output)[
i*rings +
j] = cloud->at(
i*
step*rings +
j);
613 else if(cloud->height > 1)
617 uFormat(
"Decimation of depth images should be exact! (decimation=%d, size=%dx%d)",
618 step, cloud->width, cloud->height).c_str());
620 int finalSize = cloud->height/
step * cloud->width/
step;
621 output->resize(finalSize);
622 output->width = cloud->width/
step;
623 output->height = cloud->height/
step;
625 for(
unsigned int j=0;
j<output->height; ++
j)
627 for(
unsigned int i=0;
i<output->width; ++
i)
629 output->at(
j*output->width +
i) = cloud->at(
j*output->width*
step +
i*
step);
635 int finalSize =
int(cloud->size())/
step;
636 output->resize(finalSize);
638 for(
unsigned int i=0;
i<cloud->size()-
step+1;
i+=
step)
640 (*output)[oi++] = cloud->at(
i);
646 pcl::PointCloud<pcl::PointXYZ>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
int step)
648 return downsampleImpl<pcl::PointXYZ>(cloud,
step);
650 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
int step)
652 return downsampleImpl<pcl::PointXYZRGB>(cloud,
step);
654 pcl::PointCloud<pcl::PointXYZI>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
int step)
656 return downsampleImpl<pcl::PointXYZI>(cloud,
step);
658 pcl::PointCloud<pcl::PointNormal>::Ptr
downsample(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
int step)
660 return downsampleImpl<pcl::PointNormal>(cloud,
step);
662 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
int step)
664 return downsampleImpl<pcl::PointXYZRGBNormal>(cloud,
step);
666 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
downsample(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
int step)
668 return downsampleImpl<pcl::PointXYZINormal>(cloud,
step);
671 template<
typename Po
intT>
673 const typename pcl::PointCloud<PointT>::Ptr & cloud,
674 const pcl::IndicesPtr & indices,
679 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
680 if((cloud->is_dense && cloud->size()) || (!cloud->is_dense && !
indices->empty()))
682 Eigen::Vector4f min_p, max_p;
685 pcl::getMinMax3D<PointT>(*cloud, min_p, max_p);
687 pcl::getMinMax3D<PointT>(*cloud, *
indices, min_p, max_p);
690 float inverseVoxelSize = 1.0f/voxelSize;
697 UWARN(
"Leaf size is too small for the input dataset. Integer indices would overflow. "
698 "We will split space to be able to voxelize (lvl=%d cloud=%d min=[%f %f %f] max=[%f %f %f] voxel=%f).",
701 min_p[0], min_p[1], min_p[2],
702 max_p[0], max_p[1], max_p[2],
704 pcl::IndicesPtr denseIndices;
707 denseIndices.reset(
new std::vector<int>(cloud->size()));
708 for(
size_t i=0;
i<cloud->size(); ++
i)
710 denseIndices->at(
i) =
i;
714 Eigen::Vector4f mid = (max_p-min_p)/2.0
f;
715 int zMax = max_p[2]-min_p[2] < 10?1:2;
716 for(
int x=0;
x<2; ++
x)
718 for(
int y=0;
y<2; ++
y)
720 for(
int z=0;
z<zMax; ++
z)
722 Eigen::Vector4f
m = min_p+Eigen::Vector4f(mid[0]*
x,mid[1]*
y,mid[2]*
z,0);
723 Eigen::Vector4f mx =
m+mid;
732 *output+=*voxelizeImpl<PointT>(cloud,
ind, voxelSize,
level+1);
740 pcl::VoxelGrid<PointT> filter;
741 filter.setLeafSize(voxelSize, voxelSize, voxelSize);
742 filter.setInputCloud(cloud);
745 output->resize(cloud->size());
751 filter.filter(*output);
754 else if(cloud->size() && !cloud->is_dense &&
indices->size() == 0)
756 UWARN(
"Cannot voxelize a not dense (organized) cloud with empty indices! (input=%d pts). Returning empty cloud!", (
int)cloud->size());
761 pcl::PointCloud<pcl::PointXYZ>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
763 return voxelizeImpl<pcl::PointXYZ>(cloud,
indices, voxelSize);
765 pcl::PointCloud<pcl::PointNormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
767 return voxelizeImpl<pcl::PointNormal>(cloud,
indices, voxelSize);
769 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
771 return voxelizeImpl<pcl::PointXYZRGB>(cloud,
indices, voxelSize);
773 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
775 return voxelizeImpl<pcl::PointXYZRGBNormal>(cloud,
indices, voxelSize);
777 pcl::PointCloud<pcl::PointXYZI>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
779 return voxelizeImpl<pcl::PointXYZI>(cloud,
indices, voxelSize);
781 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float voxelSize)
783 return voxelizeImpl<pcl::PointXYZINormal>(cloud,
indices, voxelSize);
786 pcl::PointCloud<pcl::PointXYZ>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
float voxelSize)
788 pcl::IndicesPtr
indices(
new std::vector<int>);
791 pcl::PointCloud<pcl::PointNormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
float voxelSize)
793 pcl::IndicesPtr
indices(
new std::vector<int>);
796 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
float voxelSize)
798 pcl::IndicesPtr
indices(
new std::vector<int>);
801 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
float voxelSize)
803 pcl::IndicesPtr
indices(
new std::vector<int>);
806 pcl::PointCloud<pcl::PointXYZI>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
float voxelSize)
808 pcl::IndicesPtr
indices(
new std::vector<int>);
811 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
voxelize(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
float voxelSize)
813 pcl::IndicesPtr
indices(
new std::vector<int>);
817 template<
typename Po
intT>
819 const typename pcl::PointCloud<PointT>::Ptr & cloud,
int samples)
822 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
823 pcl::RandomSample<PointT> filter;
825 filter.setSeed (std::rand ());
826 filter.setInputCloud(cloud);
827 filter.filter(*output);
830 pcl::PointCloud<pcl::PointXYZ>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
int samples)
832 return randomSamplingImpl<pcl::PointXYZ>(cloud,
samples);
834 pcl::PointCloud<pcl::PointNormal>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
int samples)
836 return randomSamplingImpl<pcl::PointNormal>(cloud,
samples);
838 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
int samples)
840 return randomSamplingImpl<pcl::PointXYZRGB>(cloud,
samples);
842 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
int samples)
844 return randomSamplingImpl<pcl::PointXYZRGBNormal>(cloud,
samples);
846 pcl::PointCloud<pcl::PointXYZI>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
int samples)
848 return randomSamplingImpl<pcl::PointXYZI>(cloud,
samples);
850 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
randomSampling(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
int samples)
852 return randomSamplingImpl<pcl::PointXYZINormal>(cloud,
samples);
855 template<
typename Po
intT>
857 const typename pcl::PointCloud<PointT>::Ptr & cloud,
858 const pcl::IndicesPtr & indices,
859 const std::string &
axis,
867 pcl::IndicesPtr output(
new std::vector<int>);
868 pcl::PassThrough<PointT> filter;
869 filter.setNegative(negative);
870 filter.setFilterFieldName(
axis);
871 filter.setFilterLimits(
min,
max);
872 filter.setInputCloud(cloud);
874 filter.filter(*output);
878 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
882 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
884 return passThroughImpl<pcl::PointXYZRGB>(cloud,
indices,
axis,
min,
max, negative);
886 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
888 return passThroughImpl<pcl::PointXYZI>(cloud,
indices,
axis,
min,
max, negative);
890 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
892 return passThroughImpl<pcl::PointNormal>(cloud,
indices,
axis,
min,
max, negative);
894 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
896 return passThroughImpl<pcl::PointXYZRGBNormal>(cloud,
indices,
axis,
min,
max, negative);
898 pcl::IndicesPtr
passThrough(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
const std::string &
axis,
float min,
float max,
bool negative)
900 return passThroughImpl<pcl::PointXYZINormal>(cloud,
indices,
axis,
min,
max, negative);
903 template<
typename Po
intT>
905 const typename pcl::PointCloud<PointT>::Ptr & cloud,
906 const std::string &
axis,
914 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
915 pcl::PassThrough<PointT> filter;
916 filter.setNegative(negative);
917 filter.setFilterFieldName(
axis);
918 filter.setFilterLimits(
min,
max);
919 filter.setInputCloud(cloud);
920 filter.filter(*output);
923 pcl::PointCloud<pcl::PointXYZ>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
925 return passThroughImpl<pcl::PointXYZ>(cloud,
axis,
min ,
max, negative);
927 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
929 return passThroughImpl<pcl::PointXYZRGB>(cloud,
axis,
min ,
max, negative);
931 pcl::PointCloud<pcl::PointXYZI>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
933 return passThroughImpl<pcl::PointXYZI>(cloud,
axis,
min ,
max, negative);
935 pcl::PointCloud<pcl::PointNormal>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
937 return passThroughImpl<pcl::PointNormal>(cloud,
axis,
min ,
max, negative);
939 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
941 return passThroughImpl<pcl::PointXYZRGBNormal>(cloud,
axis,
min ,
max, negative);
943 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
passThrough(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const std::string &
axis,
float min,
float max,
bool negative)
945 return passThroughImpl<pcl::PointXYZINormal>(cloud,
axis,
min ,
max, negative);
948 template<
typename Po
intT>
950 const typename pcl::PointCloud<PointT>::Ptr & cloud,
951 const pcl::IndicesPtr & indices,
952 const Eigen::Vector4f &
min,
953 const Eigen::Vector4f &
max,
959 pcl::IndicesPtr output(
new std::vector<int>);
960 pcl::CropBox<PointT> filter;
961 filter.setNegative(negative);
966 filter.setTransform(
transform.toEigen3f());
968 filter.setInputCloud(cloud);
970 filter.filter(*output);
974 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)
978 pcl::IndicesPtr output(
new std::vector<int>);
979 pcl::CropBox<pcl::PCLPointCloud2> filter;
980 filter.setNegative(negative);
985 filter.setTransform(
transform.toEigen3f());
987 filter.setInputCloud(cloud);
989 filter.filter(*output);
992 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)
996 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)
1000 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)
1004 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)
1008 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)
1012 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)
1017 template<
typename Po
intT>
1019 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1020 const Eigen::Vector4f &
min,
1021 const Eigen::Vector4f &
max,
1027 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
1028 pcl::CropBox<PointT> filter;
1029 filter.setNegative(negative);
1034 filter.setTransform(
transform.toEigen3f());
1036 filter.setInputCloud(cloud);
1037 filter.filter(*output);
1040 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)
1042 return cropBoxImpl<pcl::PointXYZ>(cloud,
min,
max,
transform, negative);
1044 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)
1046 return cropBoxImpl<pcl::PointNormal>(cloud,
min,
max,
transform, negative);
1048 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)
1050 return cropBoxImpl<pcl::PointXYZRGB>(cloud,
min,
max,
transform, negative);
1052 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)
1054 return cropBoxImpl<pcl::PointXYZI>(cloud,
min,
max,
transform, negative);
1056 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)
1058 return cropBoxImpl<pcl::PointXYZINormal>(cloud,
min,
max,
transform, negative);
1060 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)
1062 return cropBoxImpl<pcl::PointXYZRGBNormal>(cloud,
min,
max,
transform, negative);
1065 template<
typename Po
intT>
1067 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1068 const pcl::IndicesPtr & indices,
1070 float horizontalFOV,
1072 float nearClipPlaneDistance,
1073 float farClipPlaneDistance,
1076 UASSERT(horizontalFOV > 0.0
f && verticalFOV > 0.0
f);
1077 UASSERT(farClipPlaneDistance > nearClipPlaneDistance);
1080 pcl::IndicesPtr output(
new std::vector<int>);
1081 pcl::FrustumCulling<PointT> fc;
1082 fc.setNegative(negative);
1083 fc.setInputCloud (cloud);
1088 fc.setVerticalFOV (verticalFOV);
1089 fc.setHorizontalFOV (horizontalFOV);
1090 fc.setNearPlaneDistance (nearClipPlaneDistance);
1091 fc.setFarPlaneDistance (farClipPlaneDistance);
1093 fc.setCameraPose (cameraPose.
toEigen4f());
1094 fc.filter (*output);
1098 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)
1100 return frustumFilteringImpl<pcl::PointXYZ>(cloud,
indices, cameraPose, horizontalFOV, verticalFOV, nearClipPlaneDistance, farClipPlaneDistance, negative);
1103 template<
typename Po
intT>
1105 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1107 float horizontalFOV,
1109 float nearClipPlaneDistance,
1110 float farClipPlaneDistance,
1113 UASSERT(horizontalFOV > 0.0
f && verticalFOV > 0.0
f);
1114 UASSERT(farClipPlaneDistance > nearClipPlaneDistance);
1117 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
1118 pcl::FrustumCulling<PointT> fc;
1119 fc.setNegative(negative);
1120 fc.setInputCloud (cloud);
1121 fc.setVerticalFOV (verticalFOV);
1122 fc.setHorizontalFOV (horizontalFOV);
1123 fc.setNearPlaneDistance (nearClipPlaneDistance);
1124 fc.setFarPlaneDistance (farClipPlaneDistance);
1126 fc.setCameraPose (cameraPose.
toEigen4f());
1127 fc.filter (*output);
1131 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)
1133 return frustumFilteringImpl<pcl::PointXYZ>(cloud, cameraPose, horizontalFOV, verticalFOV, nearClipPlaneDistance, farClipPlaneDistance, negative);
1135 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)
1137 return frustumFilteringImpl<pcl::PointXYZRGB>(cloud, cameraPose, horizontalFOV, verticalFOV, nearClipPlaneDistance, farClipPlaneDistance, negative);
1141 template<
typename Po
intT>
1143 const typename pcl::PointCloud<PointT>::Ptr & cloud)
1145 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
1152 return removeNaNFromPointCloudImpl<pcl::PointXYZ>(cloud);
1156 return removeNaNFromPointCloudImpl<pcl::PointXYZRGB>(cloud);
1160 return removeNaNFromPointCloudImpl<pcl::PointXYZI>(cloud);
1165 pcl::PCLPointCloud2::Ptr output(
new pcl::PCLPointCloud2);
1166 output->fields = cloud->fields;
1167 output->header = cloud->header;
1169 output->point_step = cloud->point_step;
1170 output->is_dense =
true;
1171 output->data.resize(cloud->row_step*cloud->height);
1174 for(
size_t i=0;
i<cloud->fields.size(); ++
i)
1176 if(cloud->fields[
i].name.compare(
"z") == 0)
1186 for (
size_t row = 0;
row < cloud->height; ++
row)
1189 for (
size_t col = 0;
col < cloud->width; ++
col)
1192 const float *
x = (
const float*)&msg_data[0];
1193 const float *
y = (
const float*)&msg_data[4];
1194 const float *
z = (
const float*)&msg_data[is3D?8:4];
1197 memcpy (output_data, msg_data, cloud->point_step);
1198 output_data += cloud->point_step;
1204 output->row_step = output->width*output->point_step;
1205 output->data.resize(output->row_step);
1209 template<
typename Po
intT>
1211 const typename pcl::PointCloud<PointT>::Ptr & cloud)
1213 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
1219 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud)
1221 return removeNaNNormalsFromPointCloudImpl<pcl::PointNormal>(cloud);
1224 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud)
1226 return removeNaNNormalsFromPointCloudImpl<pcl::PointXYZRGBNormal>(cloud);
1229 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud)
1231 return removeNaNNormalsFromPointCloudImpl<pcl::PointXYZINormal>(cloud);
1235 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1237 pcl::IndicesPtr
indices(
new std::vector<int>);
1240 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1242 pcl::IndicesPtr
indices(
new std::vector<int>);
1245 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1247 pcl::IndicesPtr
indices(
new std::vector<int>);
1250 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1252 pcl::IndicesPtr
indices(
new std::vector<int>);
1255 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1257 pcl::IndicesPtr
indices(
new std::vector<int>);
1260 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
float radiusSearch,
int minNeighborsInRadius)
1262 pcl::IndicesPtr
indices(
new std::vector<int>);
1266 template<
typename Po
intT>
1268 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1269 const pcl::IndicesPtr & indices,
1271 int minNeighborsInRadius)
1273 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
false));
1277 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1280 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1283 std::vector<float> kDistances;
1284 int k =
tree->radiusSearch(cloud->at(
indices->at(
i)), radiusSearch,
kIndices, kDistances, minNeighborsInRadius+1);
1285 if(k > minNeighborsInRadius)
1295 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1297 tree->setInputCloud(cloud);
1298 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1301 std::vector<float> kDistances;
1302 int k =
tree->radiusSearch(cloud->at(
i), radiusSearch,
kIndices, kDistances, minNeighborsInRadius+1);
1303 if(k > minNeighborsInRadius)
1305 output->at(oi++) =
i;
1313 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1315 return radiusFilteringImpl<pcl::PointXYZ>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1317 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1319 return radiusFilteringImpl<pcl::PointNormal>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1321 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1323 return radiusFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1325 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1327 return radiusFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1329 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1331 return radiusFilteringImpl<pcl::PointXYZI>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1333 pcl::IndicesPtr
radiusFiltering(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
1335 return radiusFilteringImpl<pcl::PointXYZINormal>(cloud,
indices, radiusSearch, minNeighborsInRadius);
1339 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
1340 const std::vector<int> & viewpointIndices,
1341 const std::map<int, Transform> & viewpoints,
1343 float neighborScale)
1345 pcl::IndicesPtr
indices(
new std::vector<int>);
1349 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
1350 const std::vector<int> & viewpointIndices,
1351 const std::map<int, Transform> & viewpoints,
1353 float neighborScale)
1355 pcl::IndicesPtr
indices(
new std::vector<int>);
1359 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1360 const std::vector<int> & viewpointIndices,
1361 const std::map<int, Transform> & viewpoints,
1363 float neighborScale)
1365 pcl::IndicesPtr
indices(
new std::vector<int>);
1369 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1370 const std::vector<int> & viewpointIndices,
1371 const std::map<int, Transform> & viewpoints,
1373 float neighborScale)
1375 pcl::IndicesPtr
indices(
new std::vector<int>);
1379 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
1380 const std::vector<int> & viewpointIndices,
1381 const std::map<int, Transform> & viewpoints,
1383 float neighborScale)
1385 pcl::IndicesPtr
indices(
new std::vector<int>);
1389 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
1390 const std::vector<int> & viewpointIndices,
1391 const std::map<int, Transform> & viewpoints,
1393 float neighborScale)
1395 pcl::IndicesPtr
indices(
new std::vector<int>);
1399 template<
typename Po
intT>
1401 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1402 const pcl::IndicesPtr & indices,
1403 const std::vector<int> & viewpointIndices,
1404 const std::map<int, Transform> & viewpoints,
1406 float neighborScale)
1408 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
false));
1410 UASSERT(cloud->size() == viewpointIndices.size());
1416 std::vector<bool> kept(
indices->size());
1422 std::vector<float> kDistances;
1423 std::map<int, Transform>::const_iterator viewpointIter = viewpoints.find(viewpointIndices[index]);
1424 UASSERT(viewpointIter != viewpoints.end());
1425 cv::Point3f viewpoint(viewpointIter->second.x(), viewpointIter->second.y(), viewpointIter->second.z());
1426 cv::Point3f
point = cv::Point3f(cloud->at(index).x,cloud->at(index).y, cloud->at(index).z);
1427 float radiusSearch = factor * cv::norm(viewpoint-
point);
1428 int k =
tree->radiusSearch(cloud->at(index), radiusSearch,
kIndices, kDistances);
1430 for(
int j=0;
j<k && keep; ++
j)
1435 cv::Point3f tmp = pointTmp -
point;
1436 float distPtSqr = tmp.dot(tmp);
1437 viewpointIter = viewpoints.find(viewpointIndices[
kIndices[
j]]);
1438 UASSERT(viewpointIter != viewpoints.end());
1439 viewpoint = cv::Point3f(viewpointIter->second.x(), viewpointIter->second.y(), viewpointIter->second.z());
1440 float radiusSearchTmp = factor * cv::norm(viewpoint-pointTmp) * neighborScale;
1441 if(distPtSqr > radiusSearchTmp*radiusSearchTmp)
1449 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1463 std::vector<bool> kept(cloud->size());
1464 tree->setInputCloud(cloud);
1465 #pragma omp parallel for
1466 for(
int i=0;
i<(
int)cloud->size(); ++
i)
1469 std::vector<float> kDistances;
1470 std::map<int, Transform>::const_iterator viewpointIter = viewpoints.find(viewpointIndices[
i]);
1471 UASSERT(viewpointIter != viewpoints.end());
1472 cv::Point3f viewpoint(viewpointIter->second.x(), viewpointIter->second.y(), viewpointIter->second.z());
1473 cv::Point3f
point = cv::Point3f(cloud->at(
i).x,cloud->at(
i).y, cloud->at(
i).z);
1474 float radiusSearch = factor * cv::norm(viewpoint-
point);
1475 int k =
tree->radiusSearch(cloud->at(
i), radiusSearch,
kIndices, kDistances);
1477 for(
int j=0;
j<k && keep; ++
j)
1482 cv::Point3f tmp = pointTmp -
point;
1483 float distPtSqr = tmp.dot(tmp);
1484 viewpointIter = viewpoints.find(viewpointIndices[
kIndices[
j]]);
1485 UASSERT(viewpointIter != viewpoints.end());
1486 viewpoint = cv::Point3f(viewpointIter->second.x(), viewpointIter->second.y(), viewpointIter->second.z());
1487 float radiusSearchTmp = factor * cv::norm(viewpoint-pointTmp) * neighborScale;
1488 if(distPtSqr > radiusSearchTmp*radiusSearchTmp)
1496 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1498 for(
size_t i=0;
i<cloud->size(); ++
i)
1502 output->at(oi++) =
i;
1511 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
1512 const pcl::IndicesPtr & indices,
1513 const std::vector<int> & viewpointIndices,
1514 const std::map<int, Transform> & viewpoints,
1516 float neighborScale)
1518 return proportionalRadiusFilteringImpl<pcl::PointXYZ>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1521 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
1522 const pcl::IndicesPtr & indices,
1523 const std::vector<int> & viewpointIndices,
1524 const std::map<int, Transform> & viewpoints,
1526 float neighborScale)
1528 return proportionalRadiusFilteringImpl<pcl::PointNormal>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1531 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1532 const pcl::IndicesPtr & indices,
1533 const std::vector<int> & viewpointIndices,
1534 const std::map<int, Transform> & viewpoints,
1536 float neighborScale)
1538 return proportionalRadiusFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1541 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1542 const pcl::IndicesPtr & indices,
1543 const std::vector<int> & viewpointIndices,
1544 const std::map<int, Transform> & viewpoints,
1546 float neighborScale)
1548 return proportionalRadiusFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1551 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
1552 const pcl::IndicesPtr & indices,
1553 const std::vector<int> & viewpointIndices,
1554 const std::map<int, Transform> & viewpoints,
1556 float neighborScale)
1558 return proportionalRadiusFilteringImpl<pcl::PointXYZI>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1561 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
1562 const pcl::IndicesPtr & indices,
1563 const std::vector<int> & viewpointIndices,
1564 const std::map<int, Transform> & viewpoints,
1566 float neighborScale)
1568 return proportionalRadiusFilteringImpl<pcl::PointXYZINormal>(cloud,
indices, viewpointIndices, viewpoints, factor, neighborScale);
1572 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1573 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & substractCloud,
1575 int minNeighborsInRadius)
1577 pcl::IndicesPtr
indices(
new std::vector<int>);
1579 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
out(
new pcl::PointCloud<pcl::PointXYZRGB>);
1580 pcl::copyPointCloud(*cloud, *indicesOut, *
out);
1584 template<
typename Po
intT>
1586 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1587 const pcl::IndicesPtr & indices,
1588 const typename pcl::PointCloud<PointT>::Ptr & substractCloud,
1589 const pcl::IndicesPtr & substractIndices,
1591 int minNeighborsInRadius)
1593 UASSERT(minNeighborsInRadius > 0);
1594 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
false));
1598 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1600 if(substractIndices->size())
1602 tree->setInputCloud(substractCloud, substractIndices);
1606 tree->setInputCloud(substractCloud);
1608 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1611 std::vector<float> kDistances;
1613 if(k < minNeighborsInRadius)
1623 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1625 if(substractIndices->size())
1627 tree->setInputCloud(substractCloud, substractIndices);
1631 tree->setInputCloud(substractCloud);
1633 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1636 std::vector<float> kDistances;
1637 int k =
tree->radiusSearch(cloud->at(
i), radiusSearch,
kIndices, kDistances);
1638 if(k < minNeighborsInRadius)
1640 output->at(oi++) =
i;
1648 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1649 const pcl::IndicesPtr & indices,
1650 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & substractCloud,
1651 const pcl::IndicesPtr & substractIndices,
1653 int minNeighborsInRadius)
1655 return subtractFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, substractCloud, substractIndices, radiusSearch, minNeighborsInRadius);
1659 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
1660 const pcl::PointCloud<pcl::PointNormal>::Ptr & substractCloud,
1663 int minNeighborsInRadius)
1665 pcl::IndicesPtr
indices(
new std::vector<int>);
1667 pcl::PointCloud<pcl::PointNormal>::Ptr
out(
new pcl::PointCloud<pcl::PointNormal>);
1668 pcl::copyPointCloud(*cloud, *indicesOut, *
out);
1672 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
1673 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & substractCloud,
1676 int minNeighborsInRadius)
1678 pcl::IndicesPtr
indices(
new std::vector<int>);
1680 pcl::PointCloud<pcl::PointXYZINormal>::Ptr
out(
new pcl::PointCloud<pcl::PointXYZINormal>);
1681 pcl::copyPointCloud(*cloud, *indicesOut, *
out);
1685 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1686 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & substractCloud,
1689 int minNeighborsInRadius)
1691 pcl::IndicesPtr
indices(
new std::vector<int>);
1693 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
out(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
1694 pcl::copyPointCloud(*cloud, *indicesOut, *
out);
1698 template<
typename Po
intT>
1700 const typename pcl::PointCloud<PointT>::Ptr & cloud,
1701 const pcl::IndicesPtr & indices,
1702 const typename pcl::PointCloud<PointT>::Ptr & substractCloud,
1703 const pcl::IndicesPtr & substractIndices,
1706 int minNeighborsInRadius)
1708 UASSERT(minNeighborsInRadius > 0);
1709 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
false));
1713 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1715 if(substractIndices->size())
1717 tree->setInputCloud(substractCloud, substractIndices);
1721 tree->setInputCloud(substractCloud);
1723 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1726 std::vector<float> kDistances;
1728 if(k>=minNeighborsInRadius && maxAngle > 0.0
f)
1736 for(
int j=0; j<count && k >= minNeighborsInRadius; ++
j)
1738 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);
1744 if(
angle > maxAngle)
1760 if(k < minNeighborsInRadius)
1770 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1772 if(substractIndices->size())
1774 tree->setInputCloud(substractCloud, substractIndices);
1778 tree->setInputCloud(substractCloud);
1780 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1783 std::vector<float> kDistances;
1784 int k =
tree->radiusSearch(cloud->at(
i), radiusSearch,
kIndices, kDistances);
1785 if(k>=minNeighborsInRadius && maxAngle > 0.0
f)
1787 Eigen::Vector4f
normal(cloud->at(
i).normal_x, cloud->at(
i).normal_y, cloud->at(
i).normal_z, 0.0f);
1793 for(
int j=0; j<count && k >= minNeighborsInRadius; ++
j)
1795 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);
1801 if(
angle > maxAngle)
1817 if(k < minNeighborsInRadius)
1819 output->at(oi++) =
i;
1828 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
1829 const pcl::IndicesPtr & indices,
1830 const pcl::PointCloud<pcl::PointNormal>::Ptr & substractCloud,
1831 const pcl::IndicesPtr & substractIndices,
1834 int minNeighborsInRadius)
1836 return subtractFilteringImpl<pcl::PointNormal>(cloud,
indices, substractCloud, substractIndices, radiusSearch, maxAngle, minNeighborsInRadius);
1839 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
1840 const pcl::IndicesPtr & indices,
1841 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & substractCloud,
1842 const pcl::IndicesPtr & substractIndices,
1845 int minNeighborsInRadius)
1847 return subtractFilteringImpl<pcl::PointXYZINormal>(cloud,
indices, substractCloud, substractIndices, radiusSearch, maxAngle, minNeighborsInRadius);
1850 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1851 const pcl::IndicesPtr & indices,
1852 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & substractCloud,
1853 const pcl::IndicesPtr & substractIndices,
1856 int minNeighborsInRadius)
1858 return subtractFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, substractCloud, substractIndices, radiusSearch, maxAngle, minNeighborsInRadius);
1862 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
1863 const pcl::IndicesPtr & indices,
1864 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & substractCloud,
1865 const pcl::IndicesPtr & substractIndices,
1866 float radiusSearchRatio,
1867 int minNeighborsInRadius,
1868 const Eigen::Vector3f & viewpoint)
1870 UWARN(
"Add angle to avoid subtraction of points with opposite normals");
1871 UASSERT(minNeighborsInRadius > 0);
1873 pcl::search::KdTree<pcl::PointXYZRGB>::Ptr
tree (
new pcl::search::KdTree<pcl::PointXYZRGB>(
false));
1877 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1879 if(substractIndices->size())
1881 tree->setInputCloud(substractCloud, substractIndices);
1885 tree->setInputCloud(substractCloud);
1887 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1889 if(pcl::isFinite(cloud->at(
indices->at(
i))))
1892 std::vector<float> kSqrdDistances;
1893 float radius = radiusSearchRatio*
uNorm(
1894 cloud->at(
indices->at(
i)).x-viewpoint[0],
1895 cloud->at(
indices->at(
i)).y-viewpoint[1],
1896 cloud->at(
indices->at(
i)).z-viewpoint[2]);
1898 if(k < minNeighborsInRadius)
1909 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
1911 if(substractIndices->size())
1913 tree->setInputCloud(substractCloud, substractIndices);
1917 tree->setInputCloud(substractCloud);
1919 for(
unsigned int i=0;
i<cloud->size(); ++
i)
1921 if(pcl::isFinite(cloud->at(
i)))
1924 std::vector<float> kSqrdDistances;
1925 float radius = radiusSearchRatio*
uNorm(
1926 cloud->at(
i).x-viewpoint[0],
1927 cloud->at(
i).y-viewpoint[1],
1928 cloud->at(
i).z-viewpoint[2]);
1929 int k =
tree->radiusSearch(cloud->at(
i), radius,
kIndices, kSqrdDistances);
1930 if(k < minNeighborsInRadius)
1932 output->at(oi++) =
i;
1941 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1942 const pcl::IndicesPtr & indices,
1943 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & substractCloud,
1944 const pcl::IndicesPtr & substractIndices,
1945 float radiusSearchRatio,
1947 int minNeighborsInRadius,
1948 const Eigen::Vector3f & viewpoint)
1950 UASSERT(minNeighborsInRadius > 0);
1952 pcl::search::KdTree<pcl::PointXYZRGBNormal>::Ptr
tree (
new pcl::search::KdTree<pcl::PointXYZRGBNormal>(
false));
1956 pcl::IndicesPtr output(
new std::vector<int>(
indices->size()));
1958 if(substractIndices->size())
1960 tree->setInputCloud(substractCloud, substractIndices);
1964 tree->setInputCloud(substractCloud);
1966 for(
unsigned int i=0;
i<
indices->size(); ++
i)
1968 if(pcl::isFinite(cloud->at(
indices->at(
i))))
1971 std::vector<float> kSqrdDistances;
1972 float radius = radiusSearchRatio*
uNorm(
1973 cloud->at(
indices->at(
i)).x-viewpoint[0],
1974 cloud->at(
indices->at(
i)).y-viewpoint[1],
1975 cloud->at(
indices->at(
i)).z-viewpoint[2]);
1977 if(k>=minNeighborsInRadius && maxAngle > 0.0
f)
1985 for(
int j=0; j<count && k >= minNeighborsInRadius; ++
j)
1987 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);
1993 if(
angle > maxAngle)
2010 if(k < minNeighborsInRadius)
2021 pcl::IndicesPtr output(
new std::vector<int>(cloud->size()));
2023 if(substractIndices->size())
2025 tree->setInputCloud(substractCloud, substractIndices);
2029 tree->setInputCloud(substractCloud);
2031 for(
unsigned int i=0;
i<cloud->size(); ++
i)
2033 if(pcl::isFinite(cloud->at(
i)))
2036 std::vector<float> kSqrdDistances;
2037 float radius = radiusSearchRatio*
uNorm(
2038 cloud->at(
i).x-viewpoint[0],
2039 cloud->at(
i).y-viewpoint[1],
2040 cloud->at(
i).z-viewpoint[2]);
2041 int k =
tree->radiusSearch(cloud->at(
i), radius,
kIndices, kSqrdDistances);
2042 if(k>=minNeighborsInRadius && maxAngle > 0.0
f)
2044 Eigen::Vector4f
normal(cloud->at(
i).normal_x, cloud->at(
i).normal_y, cloud->at(
i).normal_z, 0.0f);
2050 for(
int j=0; j<count && k >= minNeighborsInRadius; ++
j)
2052 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);
2058 if(
angle > maxAngle)
2074 if(k < minNeighborsInRadius)
2076 output->at(oi++) =
i;
2087 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2089 const Eigen::Vector4f & normal,
2091 const Eigen::Vector4f & viewpoint,
2092 float groundNormalsUp)
2094 pcl::IndicesPtr
indices(
new std::vector<int>);
2098 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
2100 const Eigen::Vector4f & normal,
2102 const Eigen::Vector4f & viewpoint,
2103 float groundNormalsUp)
2105 pcl::IndicesPtr
indices(
new std::vector<int>);
2110 template<
typename Po
intT>
2112 const typename pcl::PointCloud<PointT>::Ptr & cloud,
2113 const pcl::IndicesPtr & indices,
2115 const Eigen::Vector4f & normal,
2117 const Eigen::Vector4f & viewpoint,
2118 float groundNormalsUp)
2120 pcl::IndicesPtr output(
new std::vector<int>());
2124 typename pcl::search::KdTree<PointT>::Ptr
tree(
new pcl::search::KdTree<PointT>(
false));
2126 pcl::NormalEstimationOMP<PointT, pcl::Normal> ne;
2127 ne.setInputCloud (cloud);
2139 tree->setInputCloud(cloud);
2141 ne.setSearchMethod (
tree);
2143 pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (
new pcl::PointCloud<pcl::Normal>);
2145 ne.setKSearch(normalKSearch);
2146 if(viewpoint[0] != 0 || viewpoint[1] != 0 || viewpoint[2] != 0)
2148 ne.setViewPoint(viewpoint[0], viewpoint[1], viewpoint[2]);
2151 ne.compute (*cloud_normals);
2153 output->resize(cloud_normals->size());
2155 for(
unsigned int i=0;
i<cloud_normals->size(); ++
i)
2157 Eigen::Vector4f
v(cloud_normals->at(
i).normal_x, cloud_normals->at(
i).normal_y, cloud_normals->at(
i).normal_z, 0.0f);
2158 if(groundNormalsUp>0.0
f &&
v[2] < -groundNormalsUp && cloud->at(
indices->size()!=0?
indices->at(
i):
i).z < viewpoint[3])
2165 if(
angle < angleMax)
2176 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2177 const pcl::IndicesPtr & indices,
2179 const Eigen::Vector4f & normal,
2181 const Eigen::Vector4f & viewpoint,
2182 float groundNormalsUp)
2184 return normalFilteringImpl<pcl::PointXYZ>(cloud,
indices, angleMax,
normal, normalKSearch, viewpoint, groundNormalsUp);
2187 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
2188 const pcl::IndicesPtr & indices,
2190 const Eigen::Vector4f & normal,
2192 const Eigen::Vector4f & viewpoint,
2193 float groundNormalsUp)
2195 return normalFilteringImpl<pcl::PointXYZRGB>(cloud,
indices, angleMax,
normal, normalKSearch, viewpoint, groundNormalsUp);
2198 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
2199 const pcl::IndicesPtr & indices,
2201 const Eigen::Vector4f & normal,
2203 const Eigen::Vector4f & viewpoint,
2204 float groundNormalsUp)
2206 return normalFilteringImpl<pcl::PointXYZI>(cloud,
indices, angleMax,
normal, normalKSearch, viewpoint, groundNormalsUp);
2209 template<
typename Po
intNormalT>
2211 const typename pcl::PointCloud<PointNormalT>::Ptr & cloud,
2212 const pcl::IndicesPtr & indices,
2214 const Eigen::Vector4f & normal,
2215 const Eigen::Vector4f & viewpoint,
2216 float groundNormalsUp)
2218 pcl::IndicesPtr output(
new std::vector<int>());
2225 output->resize(
indices->size());
2226 for(
unsigned int i=0;
i<
indices->size(); ++
i)
2228 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);
2229 if(groundNormalsUp>0.0
f &&
v[2] < -groundNormalsUp && cloud->at(
indices->at(
i)).z < viewpoint[3])
2235 if(
angle < angleMax)
2243 output->resize(cloud->size());
2244 for(
unsigned int i=0;
i<cloud->size(); ++
i)
2246 Eigen::Vector4f
v(cloud->at(
i).normal_x, cloud->at(
i).normal_y, cloud->at(
i).normal_z, 0.0f);
2247 if(groundNormalsUp>0.0
f &&
v[2] < -groundNormalsUp && cloud->at(
i).z < viewpoint[3])
2253 if(
angle < angleMax)
2266 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
2267 const pcl::IndicesPtr & indices,
2269 const Eigen::Vector4f & normal,
2271 const Eigen::Vector4f & viewpoint,
2272 float groundNormalsUp)
2274 return normalFilteringImpl<pcl::PointNormal>(cloud,
indices, angleMax,
normal, viewpoint, groundNormalsUp);
2277 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
2278 const pcl::IndicesPtr & indices,
2280 const Eigen::Vector4f & normal,
2282 const Eigen::Vector4f & viewpoint,
2283 float groundNormalsUp)
2285 return normalFilteringImpl<pcl::PointXYZRGBNormal>(cloud,
indices, angleMax,
normal, viewpoint, groundNormalsUp);
2288 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
2289 const pcl::IndicesPtr & indices,
2291 const Eigen::Vector4f & normal,
2293 const Eigen::Vector4f & viewpoint,
2294 float groundNormalsUp)
2296 return normalFilteringImpl<pcl::PointXYZINormal>(cloud,
indices, angleMax,
normal, viewpoint, groundNormalsUp);
2300 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2301 float clusterTolerance,
2304 int * biggestClusterIndex)
2306 pcl::IndicesPtr
indices(
new std::vector<int>);
2307 return extractClusters(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2310 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
2311 float clusterTolerance,
2314 int * biggestClusterIndex)
2316 pcl::IndicesPtr
indices(
new std::vector<int>);
2317 return extractClusters(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2320 template<
typename Po
intT>
2322 const typename pcl::PointCloud<PointT>::Ptr & cloud,
2323 const pcl::IndicesPtr & indices,
2324 float clusterTolerance,
2327 int * biggestClusterIndex)
2329 typename pcl::search::KdTree<PointT>::Ptr
tree (
new pcl::search::KdTree<PointT>(
true));
2330 pcl::EuclideanClusterExtraction<PointT> ec;
2331 ec.setClusterTolerance (clusterTolerance);
2332 ec.setMinClusterSize (minClusterSize);
2333 ec.setMaxClusterSize (maxClusterSize);
2334 ec.setInputCloud (cloud);
2343 tree->setInputCloud(cloud);
2345 ec.setSearchMethod (
tree);
2347 std::vector<pcl::PointIndices> cluster_indices;
2348 ec.extract (cluster_indices);
2351 unsigned int maxSize = 0;
2352 std::vector<pcl::IndicesPtr> output(cluster_indices.size());
2353 for(
unsigned int i=0;
i<cluster_indices.size(); ++
i)
2355 output[
i] = pcl::IndicesPtr(
new std::vector<int>(cluster_indices[
i].
indices));
2357 if(maxSize < cluster_indices[
i].
indices.size())
2359 maxSize = (
unsigned int)cluster_indices[
i].
indices.size();
2363 if(biggestClusterIndex)
2365 *biggestClusterIndex = maxIndex;
2372 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2373 const pcl::IndicesPtr & indices,
2374 float clusterTolerance,
2377 int * biggestClusterIndex)
2379 return extractClustersImpl<pcl::PointXYZ>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2382 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
2383 const pcl::IndicesPtr & indices,
2384 float clusterTolerance,
2387 int * biggestClusterIndex)
2389 return extractClustersImpl<pcl::PointNormal>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2392 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
2393 const pcl::IndicesPtr & indices,
2394 float clusterTolerance,
2397 int * biggestClusterIndex)
2399 return extractClustersImpl<pcl::PointXYZRGB>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2402 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
2403 const pcl::IndicesPtr & indices,
2404 float clusterTolerance,
2407 int * biggestClusterIndex)
2409 return extractClustersImpl<pcl::PointXYZRGBNormal>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2412 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
2413 const pcl::IndicesPtr & indices,
2414 float clusterTolerance,
2417 int * biggestClusterIndex)
2419 return extractClustersImpl<pcl::PointXYZI>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2422 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
2423 const pcl::IndicesPtr & indices,
2424 float clusterTolerance,
2427 int * biggestClusterIndex)
2429 return extractClustersImpl<pcl::PointXYZINormal>(cloud,
indices, clusterTolerance, minClusterSize, maxClusterSize, biggestClusterIndex);
2432 template<
typename Po
intT>
2434 const typename pcl::PointCloud<PointT>::Ptr & cloud,
2435 const pcl::IndicesPtr & indices,
2438 pcl::IndicesPtr output(
new std::vector<int>);
2439 pcl::ExtractIndices<PointT>
extract;
2440 extract.setInputCloud (cloud);
2442 extract.setNegative(negative);
2447 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2449 return extractIndicesImpl<pcl::PointXYZ>(cloud,
indices, negative);
2451 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2453 return extractIndicesImpl<pcl::PointNormal>(cloud,
indices, negative);
2455 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2457 return extractIndicesImpl<pcl::PointXYZRGB>(cloud,
indices, negative);
2459 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2461 return extractIndicesImpl<pcl::PointXYZRGBNormal>(cloud,
indices, negative);
2463 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2465 return extractIndicesImpl<pcl::PointXYZI>(cloud,
indices, negative);
2467 pcl::IndicesPtr
extractIndices(
const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative)
2469 return extractIndicesImpl<pcl::PointXYZINormal>(cloud,
indices, negative);
2472 template<
typename Po
intT>
2474 const typename pcl::PointCloud<PointT>::Ptr & cloud,
2475 const pcl::IndicesPtr & indices,
2479 typename pcl::PointCloud<PointT>::Ptr output(
new pcl::PointCloud<PointT>);
2480 pcl::ExtractIndices<PointT>
extract;
2481 extract.setInputCloud (cloud);
2483 extract.setNegative(negative);
2484 extract.setKeepOrganized(keepOrganized);
2488 pcl::PointCloud<pcl::PointXYZ>::Ptr
extractIndices(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative,
bool keepOrganized)
2490 return extractIndicesImpl<pcl::PointXYZ>(cloud,
indices, negative, keepOrganized);
2492 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
extractIndices(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative,
bool keepOrganized)
2494 return extractIndicesImpl<pcl::PointXYZRGB>(cloud,
indices, negative, keepOrganized);
2501 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr
extractIndices(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative,
bool keepOrganized)
2503 return extractIndicesImpl<pcl::PointXYZRGBNormal>(cloud,
indices, negative, keepOrganized);
2507 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2508 float distanceThreshold,
2510 pcl::ModelCoefficients * coefficientsOut)
2512 pcl::IndicesPtr
indices(
new std::vector<int>);
2517 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
2518 const pcl::IndicesPtr & indices,
2519 float distanceThreshold,
2521 pcl::ModelCoefficients * coefficientsOut)
2524 pcl::ModelCoefficients::Ptr coefficients (
new pcl::ModelCoefficients);
2525 pcl::PointIndices::Ptr inliers (
new pcl::PointIndices);
2527 pcl::SACSegmentation<pcl::PointXYZ> seg;
2529 seg.setOptimizeCoefficients (
true);
2530 seg.setMaxIterations (maxIterations);
2532 seg.setModelType (pcl::SACMODEL_PLANE);
2533 seg.setMethodType (pcl::SAC_RANSAC);
2534 seg.setDistanceThreshold (distanceThreshold);
2536 seg.setInputCloud (cloud);
2541 seg.segment (*inliers, *coefficients);
2545 *coefficientsOut = *coefficients;
2548 return pcl::IndicesPtr(
new std::vector<int>(inliers->indices));