ground_segmentation 1.0
Ground segmentation in pointcloud
Loading...
Searching...
No Matches
ground_segmentation::ProcessCloudProcessor< PointT > Class Template Reference

#include <pointcloud_processor.hpp>

Public Member Functions

pcl::PointCloud< PointT >::Ptr filterCloud (typename pcl::PointCloud< PointT >::Ptr cloud, bool downSampleInputCloud, float filterRes, Eigen::Vector4f minPoint, Eigen::Vector4f maxPoint, bool invertCropBox)
 
std::vector< typename pcl::PointCloud< PointT >::Ptr > euclideanClustering (typename pcl::PointCloud< PointT >::Ptr cloud, float clusterTolerance, int minSize, int maxSize)
 
void savePcd (typename pcl::PointCloud< PointT >::Ptr cloud, std::string file)
 
pcl::PointCloud< PointT >::Ptr loadPcd (std::string file)
 

Detailed Description

template<typename PointT>
class ground_segmentation::ProcessCloudProcessor< PointT >

Definition at line 35 of file pointcloud_processor.hpp.

Member Function Documentation

◆ euclideanClustering()

template<typename PointT >
std::vector< typename pcl::PointCloud< PointT >::Ptr > ground_segmentation::ProcessCloudProcessor< PointT >::euclideanClustering ( typename pcl::PointCloud< PointT >::Ptr  cloud,
float  clusterTolerance,
int  minSize,
int  maxSize 
)

Definition at line 83 of file pointcloud_processor.hpp.

87{
88 std::vector<typename pcl::PointCloud<PointT>::Ptr> clusters;
89 typename pcl::search::KdTree<PointT>::Ptr tree(new pcl::search::KdTree<PointT>);
90 tree->setInputCloud(cloud);
91
92 std::vector<pcl::PointIndices> cluster_indices;
93 pcl::EuclideanClusterExtraction<PointT> ec;
94 ec.setClusterTolerance(clusterTolerance);
95 ec.setMinClusterSize(minSize);
96 ec.setMaxClusterSize(maxSize);
97 ec.setSearchMethod(tree);
98 ec.setInputCloud(cloud);
99 ec.extract(cluster_indices);
100
101 for (const auto & cluster : cluster_indices) {
102 typename pcl::PointCloud<PointT>::Ptr cloud_cluster(new pcl::PointCloud<PointT>);
103 for (const auto & idx : cluster.indices) {
104 cloud_cluster->push_back((*cloud)[idx]);
105 }
106 cloud_cluster->width = cloud_cluster->size();
107 cloud_cluster->height = 1;
108 cloud_cluster->is_dense = true;
109 clusters.push_back(cloud_cluster);
110 }
111 return clusters;
112}

◆ filterCloud()

template<typename PointT >
pcl::PointCloud< PointT >::Ptr ground_segmentation::ProcessCloudProcessor< PointT >::filterCloud ( typename pcl::PointCloud< PointT >::Ptr  cloud,
bool  downSampleInputCloud,
float  filterRes,
Eigen::Vector4f  minPoint,
Eigen::Vector4f  maxPoint,
bool  invertCropBox 
)

Definition at line 54 of file pointcloud_processor.hpp.

62{
63 typename pcl::PointCloud<PointT>::Ptr cloud_filtered(new pcl::PointCloud<PointT>());
64 pcl::CropBox<PointT> roi;
65 roi.setMin(minPoint);
66 roi.setMax(maxPoint);
67 roi.setNegative(invertCropBox);
68
69 if (downSampleInputCloud) {
70 pcl::VoxelGrid<PointT> sor;
71 sor.setInputCloud(cloud);
72 sor.setLeafSize(filterRes, filterRes, filterRes);
73 sor.filter(*cloud_filtered);
74 roi.setInputCloud(cloud_filtered);
75 } else {
76 roi.setInputCloud(cloud);
77 }
78 roi.filter(*cloud_filtered);
79 return cloud_filtered;
80}

◆ loadPcd()

template<typename PointT >
pcl::PointCloud< PointT >::Ptr ground_segmentation::ProcessCloudProcessor< PointT >::loadPcd ( std::string  file)

Definition at line 123 of file pointcloud_processor.hpp.

124{
125 typename pcl::PointCloud<PointT>::Ptr cloud(new pcl::PointCloud<PointT>);
126 if (pcl::io::loadPCDFile<PointT>(file, *cloud) == -1) { //* load the file
127 std::cerr << "Failed to read PCD file: " << file << std::endl;
128 }
129 return cloud;
130}

◆ savePcd()

template<typename PointT >
void ground_segmentation::ProcessCloudProcessor< PointT >::savePcd ( typename pcl::PointCloud< PointT >::Ptr  cloud,
std::string  file 
)

Definition at line 115 of file pointcloud_processor.hpp.

118{
119 pcl::io::savePCDFileASCII(file, *cloud);
120}

The documentation for this class was generated from the following file: