PCL:PCL可视化显示点云
(1):引用:仅仅是简单的显示点云,可以使用CloudViewer类。这个类非常简单易用。但要注意,它不是线程安全的。如果要用于多线程,还要参考PCLVisualizer。
需要注意的是,PointCloud的数据类型要和PCD文件中或者代码中的PointT一致!
并且:CloudViewer除了显示什么也不能干.
显示代码为:
pcl::visualization::CloudViewer viewer ("Cluster viewer");
viewer.showCloud(colored_cloud);
while (!viewer.wasStopped ())
{
}
(2):PCLVisualizer详细使用规则
简单函数解释:
boost::shared_ptr<pcl::visualization::PCLVisualizer> simpleVis (pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud)
{
// --------------------------------------------
// -----Open 3D viewer and add point cloud-----
// -------------------------------------------- boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
viewer->addCoordinateSystem (1.0);
viewer->initCameraParameters (); return (viewer);
} 鼠标事件:
void mouseEventOccurred (const pcl::visualization::MouseEvent &event,
void* viewer_void)
{
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
if (event.getButton () == pcl::visualization::MouseEvent::LeftButton && event.getType () == pcl::visualization::MouseEvent::MouseButtonRelease)
{
std::cout << "Left mouse button released at position (" << event.getX () << ", " << event.getY () << ")" << std::endl;
char str[512]; sprintf (str, "text#%03d", text_id ++);
viewer->addText ("clicked here", event.getX (), event.getY (), str);
}
}
键盘交互:
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
void* viewer_void)
{
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
if (event.getKeySym () == "r" && event.keyDown ())
{
std::cout << "r was pressed => removing all text" << std::endl; char str[512];
for (unsigned int i = 0; i < text_id; ++i)
{
sprintf (str, "text#%03d", i);
viewer->removeShape (str);
}
text_id = 0;
}
}
调用函数为:
viewer->registerKeyboardCallback (keyboardEventOccurred, (void*)&viewer);
viewer->registerMouseCallback (mouseEventOccurred, (void*)&viewer);
摄像头初始化函数:
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->initCameraParameters ();
后记:
具体的使用方法还有很多,参见官方文档。
PCL:PCL可视化显示点云的更多相关文章
- PCL Show Point Cloud 显示点云
在使用PCL库的时候,经常需要显示点云,可以用下面这段代码: #include <pcl/visualization/cloud_viewer.h> pcl::PointCloud< ...
- PCL入门—点云操作 定义变量 显示点云 存储
// 定义相关变量 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr (new pcl::PointCloud<pcl::PointXYZ& ...
- PCL中的OpenNI点云获取框架(OpenNI Grabber Framework in PCL)
从PCL 1.0开始,PCL(三维点云处理库Point Cloud Library)提供了一个通用采集接口,这样可以方便地连接到不同的设备及其驱动.文件格式和其他数据源.PCL集成的第一个数据获取驱动 ...
- 在PCL中如何实现点云压缩(1)
点云由庞大的数据集组成,这些数据集通过距离.颜色.法线等附加信息来描述空间三维点.此外,点云能以非常高的速率被创建出来,因此需要占用相当大的存储资源,一旦点云需要存储或者通过速率受限制的通信信道进行传 ...
- PCL—低层次视觉—点云分割(邻近信息)
分割给人最直观的影响大概就是邻居和我不一样.比如某条界线这边是中华文明,界线那边是西方文,最简单的分割方式就是在边界上找些居民问:"小伙子,你到底能不能上油管啊?”.然后把能上油管的居民坐标 ...
- PCL—低层次视觉—点云分割(RanSaC)
点云分割 点云分割可谓点云处理的精髓,也是三维图像相对二维图像最大优势的体现.不过多插一句,自Niloy J Mitra教授的Global contrast based salient region ...
- PCL 不同类型的点云之间进行类型转换
PCL 不同类型的点云之间进行类型转换 可以使用PCL里面现成的函数pcl::copyPointCloud(): #include <pcl/common/impl/io.h> pcl:: ...
- GeoHash原理和可视化显示
最近在做附近定位功能的产品,geohash是一个非常不错的实现方式.查询资料,发现阿里的这篇文章讲解的很好.但文中并没有给出geohash显示的工具.无奈,也没有查到类似的.只好自己简单显示一下,方便 ...
- 1.5神经网络可视化显示(matplotlib)
神经网络训练+可视化显示 #添加隐层的神经网络结构+可视化显示 import tensorflow as tf def add_layer(inputs,in_size,out_size,activa ...
随机推荐
- jquery 绑定回车(Enter )事件
全局: $(function(){ document.onkeydown = function(e){ var ev = document.all ? window.event : e; if(ev. ...
- H5-video1 iOS苹果和微信中音频和视频实现自动播放的方法
<audio preload="preload" controls id="car_audio" src="http://media.xitao ...
- 07springMVC视图解析器
u 概述 u 常见视图解析器 u UrlBasedViewResolver u InternalResourceViewResolver u 视图解析器链 u 说明 1 概述 在 ...
- EF--复杂类型
介绍EF复杂类型的文章 我理解的复杂类型就是简化了编码的操作,实际上在数据库中还是按照约定生成相应的类似"类名_类名"的表结构 public class CompanyAddres ...
- android 细节之An internal error occurred during: "Launching New_configuration".
今天在导入公司的一个小demo时候发现了一个非常有意思的错误. An internal error occurred during: "Launching New_configuration ...
- Linux 3.14 待机流程分析
1:待机节点创建 static int __init pm_init(void) { int error = pm_start_workqueue(); if (error) return error ...
- Android-68-Tomcat各种启动错误的解决的方法,如:Exception in thread "Thread-6" NoClassDefFoundError,Document base E:\
上午遇到一个棘手的事儿,导入一个project,结果把原有的Tomcatserver给导坏了.各种红的.黑的.蓝的错误满天飞啊,刚弄完一个项目,怕被毁了.我那个揪心呀! 还好.在走头无路的情况下 ...
- logo切图大小相应的尺寸
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMTQwNDYxMQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- vue组件的3种书写形式
第一种使用script标签 <!DOCTYPE html> <html> <body> <div id="app"> <my- ...
- SpringMVC 拦截器不拦截静态资源的三种处理方式方法
方案一.拦截器中增加针对静态资源不进行过滤(涉及spring-mvc.xml) <mvc:resources location="/" mapping="/**/* ...