当前位置:网站首页>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
边栏推荐
- 从MediaRecord录像中读取H264参数
- shell编程01_Shell基础
- Sum the two numbers to find the target value
- 2021-09-12
- Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
- AI技术产业热点分析
- lunix重新分配root 和 home 空间内存
- Flutter环境配置保姆级教程,让doctor一绿到底
- SQOOP 1.4.6 INSTALL
- 记录 AttributeError: ‘NoneType‘ object has no attribute ‘nextcall‘
猜你喜欢
随机推荐
02-taildir source
SUS系统可用性量表
判断数组中是否存在重复元素
ERROR 1118 (42000): Row size too large (&gt; 8126)
AI技术产业热点分析
STM32 and motor development (upper system)
互联网快讯:腾讯会议应用市场正式上线;Soul赴港递交上市申请书
Operator-1 first acquaintance with operator
[Fantasy 4] introduction and use of UMG components (under update...)
Introduction and Principle notes of UE4 material
Application of rxjs operator withlatestfrom in Spartacus UI of SAP e-commerce cloud
两数之和,求目标值
SAP Spartacus express checkout design
【避坑指南】Unity3D项目接入腾讯Bugly工具时遇到的坑
axis设备的rtsp setup头中的url不能带参
Solution of mysql8 forgetting password file in Windows Environment
对话吴纲:我为什么笃信“大国品牌”的崛起?
数据库字典Navicat自动生成版本
js promise. all
【Unity3D】制作进度条——让Image同时具有Filled和Sliced的功能