当前位置:网站首页>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
边栏推荐
- 使用Windbg静态分析dump文件(实战经验总结)
- Lunix reallocates root and home space memory
- 【Unity3D】制作进度条——让Image同时具有Filled和Sliced的功能
- 01-spooldir
- 【JetBrain Rider】构建项目出现异常:未找到导入的项目“D:\VisualStudio2017\IDE\MSBuild\15.0\Bin\Roslyn\Microsoft.CSh
- 07 data import sqoop
- Zlib download and use
- [unity3d] nested use layout group to make scroll view with dynamic sub object height
- pytest框架实现前后置
- Kustomize使用手册
猜你喜欢
(五)APA场景搭建之挡位控制设置
从MediaRecord录像中读取H264参数
Application of rxjs operator withlatestfrom in Spartacus UI of SAP e-commerce cloud
Pytest framework implements pre post
01 install virtual machine
Shapiro Wilk normal analysis by SPSS
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
[pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces
Considerations for Apache deploying static web page projects
LeetCode+ 76 - 80 暴搜专题
随机推荐
Pywin32打开指定窗口
(五)APA场景搭建之挡位控制设置
ERROR 1118 (42000): Row size too large (&gt; 8126)
Stm32 et développement de moteurs (système supérieur)
[visual studio] every time you open a script of unity3d, a new vs2017 will be automatically reopened
Shutter - canvas custom graph
【MySQL】连接MySQL时出现异常:Connection must be valid and open
14. Code implementation of semaphore
Flink实时计算topN热榜
Aiphacode is not a substitute for programmers, but a tool for developers
Use WinDbg to statically analyze dump files (summary of practical experience)
2021-10-02
axis设备的rtsp setup头中的url不能带参
Flink calculates topn hot list in real time
618再次霸榜的秘密何在?耐克最新财报给出答案
01-spooldir
测试--面试题总结
js setTimeout()与面试题
SQOOP 1.4.6 INSTALL
Transport Optimization abstraction