当前位置:网站首页>Filtering of PCL
Filtering of PCL
2022-07-02 10:56:00 【AICVer】
Pass through filtering
Pass through filtering preserves points within a specified range .
#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
int main(int argc, char **argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
cloud->width = 5;
cloud->height = 1;
cloud->points.resize(cloud->width * cloud->height);
for (auto &point : *cloud) // Fill the point cloud
{
point.x = 1024 * rand() / (RAND_MAX + 1.0f);
point.y = 1024 * rand() / (RAND_MAX + 1.0f);
point.z = 1024 * rand() / (RAND_MAX + 1.0f);
}
cloud->points[0].z = 1;// To test the boundary conditions
cloud->points[1].z = 0;
std::cerr << "Cloud before filtering: " << std::endl;
for (const auto &point : *cloud)
std::cerr << " " << point.x << " "
<< point.y << " "
<< point.z << std::endl;
// Create the filtering object
// Set the filter object
pcl::PassThrough<pcl::PointXYZ> pass;
pass.setInputCloud(cloud); // Enter the point cloud
pass.setFilterFieldName("z"); // Filter field
// It's only reserved here 0.0 < z < 1.0 Point cloud of
pass.setFilterLimits(0.0, 1.0); // Set the range of filter fields
//setFilterLimitsNegative The default setting is false. If you set true, said setFilterLimits Filter out the points in the range
//pass.setFilterLimitsNegative (true);
pass.filter(*cloud_filtered); // filtering , And output to the cloud_filtered, But the input cloud No change
std::cerr << "Cloud before filtering:cloud " << std::endl;
for (const auto &point : *cloud)
std::cerr << " " << point.x << " "
<< point.y << " "
<< point.z << std::endl;
std::cerr << "Cloud after filtering: cloud_filtered" << std::endl;
for (const auto &point : *cloud_filtered)
std::cerr << " " << point.x << " "
<< point.y << " "
<< point.z << std::endl;
return (0);
}
Sampling under voxel filtering
#include <iostream>
#include <pcl/filters/voxel_grid.h>// Voxel filter header file
#include <pcl/io/pcd_io.h> //PCD Read and write class related header files
#include <pcl/point_types.h> // Point type related definitions
#include <pcl/visualization/cloud_viewer.h> // Point cloud visualization related definitions Visual support header file
#include <pcl/common/common.h> //common modular ,common.h The functions of are pcl::getMinMax3D
int main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>());
// Fill in point cloud data
pcl::PCDReader reader;
// Change the path to the path where you store your files
reader.read ("D:\\pclcode\\filter\\voxel_grid\\source\\table_scene_lms400.pcd", *cloud); // Read the folder table_scene_lms400.pcd Point cloud file
//pcl::visualization::CloudViewer viewer("cloud viewer");// Show
//viewer.showCloud(cloud);// Show cloud
std::cerr << "PointCloud before filtering: " << cloud->width * cloud->height
<< " data points (" << pcl::getFieldsList(*cloud) << ").";// Output the total number of points before filtering
//system("pause");// Pause
// Create filter object
pcl::VoxelGrid<pcl::PointXYZ> sor;// Create filter object
sor.setInputCloud (cloud);// Set the input point cloud
sor.setLeafSize (0.01f, 0.01f, 0.01f);// The voxel size is set to 10*10*10cm
sor.filter (*cloud_filtered);// Perform filtering , Save the filter results in cloud_filtered
std::cerr << "PointCloud after filtering: " << cloud_filtered->width * cloud_filtered->height
<< " data points (" << pcl::getFieldsList (*cloud_filtered) << ").";// Output the total number of filtered
pcl::PCDWriter writer;//pcd Write operations
writer.write ("2f.pcd", *cloud_filtered);// Store the filtered point cloud in build Folder , And named it 2f.pcd
//pcl::visualization::CloudViewer viewer("cloud viewer");// Show
//viewer.showCloud(cloud_filterd);// Show cloud
system("pause");// Pause
return (0);
}
//PointCloud before filtering : 460400 data points(x y z).
//PointCloud after filtering : 41049 data points(x y z).
// Please press any key to continue . . .
边栏推荐
- Hdu1236 ranking (structure Sorting)
- PCL 投影点云
- JSP webshell free -- webshell free
- "Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
- 使用sqlcipher打开加密的sqlite方法
- 【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
- In the face of uncertainty, the role of supply chain
- Point cloud projection picture
- 01-spooldir
- stm32和電機開發(上比特系統)
猜你喜欢

Leetcode+ 76 - 80 storm search topic

stm32和電機開發(上比特系統)

Kustomize user manual
![2.hacking-lab脚本关[详细writeup]](/img/f3/29745761cd5ad4df84c78ac904ea51.png)
2.hacking-lab脚本关[详细writeup]

【AppLinking实战案例】通过AppLinking分享应用内图片

Jsp webshell Free from killing - The Foundation of JSP

How to get the password of cpolar?

Is this code PHP MySQL redundant?

MYSQL环境配置

UVM learning - object attribute of UVM phase
随机推荐
Windows环境MySQL8忘记密码文件解决方案
UWA report uses tips. Did you get it? (the fourth bullet)
Transport Optimization abstraction
In the face of uncertainty, the role of supply chain
Introduction to MySQL 8 DBA foundation tutorial
Hdu1228 a + B (map mapping)
Kustomize user manual
1287_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
MySQL environment configuration
从MediaRecord录像中读取H264参数
"Matching" is true love, a new attitude for young people to make friends
Open the encrypted SQLite method with sqlcipher
AttributeError: type object ‘Image‘ has no attribute ‘fromarray‘
618再次霸榜的秘密何在?耐克最新财报给出答案
2.hacking-lab脚本关[详细writeup]
Analysis of hot spots in AI technology industry
Win11 arm系统配置.net core环境变量
Jsp webshell Free from killing - The Foundation of JSP
Database dictionary Navicat automatic generation version