当前位置:网站首页>PCL 投影点云
PCL 投影点云
2022-07-02 07:00:00 【AICVer】
投影到XOY平面上
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/filters/project_inliers.h>
#include <pcl/visualization/pcl_visualizer.h>
using namespace std;
using namespace pcl;
void visualize(PointCloud<PointXYZ>::Ptr source, PointCloud<PointXYZ>::Ptr target)
{
visualization::PCLVisualizer viewer("Point Cloud Viewer");
// 创建两个显示窗口
int v1, v2;
viewer.createViewPort(0, 0.0, 0.5, 1.0, v1);
viewer.createViewPort(0.5, 0.0, 1.0, 1.0, v2);
// 设置背景颜色
viewer.setBackgroundColor(255, 255, 255, v1);
viewer.setBackgroundColor(255, 255, 255, v2);
// 给点云添加颜色
visualization::PointCloudColorHandlerCustom<PointXYZ> source_color(source, 0, 0, 255); // blue
visualization::PointCloudColorHandlerCustom<PointXYZ> target_color(target, 255, 0, 0); // red
// 添加点云到显示窗口
viewer.addPointCloud(source, source_color, "source cloud", v1);
viewer.addPointCloud(target, target_color, "target cloud", v2);
while (!viewer.wasStopped())
{
viewer.spinOnce(100);
boost::this_thread::sleep(boost::posix_time::microseconds(100000));
}
}
int main(int argc, char** argv)
{
PointCloud<PointXYZ>::Ptr cloud(new pcl::PointCloud<PointXYZ>);
PointCloud<PointXYZ>::Ptr filtered_cloud(new pcl::PointCloud<PointXYZ>);
io::loadPCDFile("D:\\Data\\rabbit.pcd", *cloud);
// 输出滤波前点的个数
cout << "滤波前有:" << cloud->points.size() << "个点" << endl;
// 设置模型参数的系数
ModelCoefficients::Ptr coefficients(new ModelCoefficients());
coefficients->values.resize(4);
coefficients->values[0] = 0;
coefficients->values[1] = 0;
coefficients->values[2] = 1.0;
coefficients->values[3] = 0;
// 实例化滤波器对象
ProjectInliers<PointXYZ> proj;
proj.setModelType(SACMODEL_PLANE);
proj.setInputCloud(cloud);
proj.setModelCoefficients(coefficients);
proj.filter(*filtered_cloud);
cout << "滤波后有:" << filtered_cloud->points.size() << "个点" << endl;
visualize(cloud, filtered_cloud);
return 0;
}
可以投影的其它模型
可以使用的投影模型如下:
平面模型:SACMODEL_PLANE
线模型:SACMODEL_LINE
平面上的二维圆:SACMODEL_CIRCLE2D
平面上的三维圆:SACMODEL_CIRCLE3D
球体模型:SACMODEL_SPHERE
圆柱模型:SACMODEL_CYLINDER
圆锥模型:SACMODEL_CONE
圆环模型:SACMODEL_TORUS
平行于给定轴的一种线模型:SACMODEL_PARALLEL_LINE
垂直于指定轴的平面模型:SACMODEL_PERPENDICULAR_PLANE
三维棒分割模型:SACMODEL_STICK
边栏推荐
- js setTimeout()与面试题
- 07 data import sqoop
- pytest--之测试报告allure配置
- Pywin32打开指定窗口
- AttributeError: type object ‘Image‘ has no attribute ‘fromarray‘
- 2021-09-12
- Blender ocean production
- Solutions to a series of problems in sqoop job creation
- Solution of mysql8 forgetting password file in Windows Environment
- 使用sqlcipher打开加密的sqlite方法
猜你喜欢

Internet News: Tencent conference application market was officially launched; Soul went to Hong Kong to submit the listing application

2021-10-02

VLAN experiment

session-cookie与token

Flink实时计算topN热榜

12. Process synchronization and semaphore

Rapid prototyping

Flutter环境配置保姆级教程,让doctor一绿到底

stm32和电机开发(上位系统)

STM32 and motor development (upper system)
随机推荐
Flink submitter
SUS系统可用性量表
MongoDB-快速上手MongoDB命令行的一些简单操作
1287_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
SQOOP 1.4.6 INSTALL
【Unity3D】制作进度条——让Image同时具有Filled和Sliced的功能
[pit avoidance guide] pit encountered by unity3d project when accessing Tencent bugly tool
AttributeError: type object ‘Image‘ has no attribute ‘fromarray‘
【教程】如何让VisualStudio的HelpViewer帮助文档独立运行
Stm32 et développement de moteurs (système supérieur)
webUI自动化学习
Importing tables from sqoop
Solution of mysql8 forgetting password file in Windows Environment
传输优化抽象
互联网快讯:腾讯会议应用市场正式上线;Soul赴港递交上市申请书
Internet News: Tencent conference application market was officially launched; Soul went to Hong Kong to submit the listing application
Ks009 implement pet management system based on SSH
Lunix reallocates root and home space memory
[tutorial] how to make the Helpviewer help document of VisualStudio run independently
axis设备的rtsp setup头中的url不能带参