用PCL刷新显示变化的点云
来源:互联网 发布:d3.js v4画力导向图 编辑:程序博客网 时间:2024/04/30 12:59
在头文件中,定义了:
int m_colorInc;//演示红色分量不断增长。这是增长步长。
在cpp文件中,刚开始,在文件最上面,打开一个3D窗口,如下面代码所示。
// PCLDemoDlg.cpp : 实现文件
//#include "stdafx.h"#include "PCLDemo.h"#include "PCLDemoDlg.h"#include "afxdialogex.h"#ifdef _DEBUG#define new DEBUG_NEW#endif//////PCL#include <iostream>#include <boost/thread/thread.hpp>#include <pcl/common/common_headers.h>#include <pcl/features/normal_3d.h>#include <pcl/io/pcd_io.h>#include <pcl/visualization/pcl_visualizer.h>#include <pcl/console/parse.h>// 用于应用程序“关于”菜单项的 CAboutDlg 对话框#include <conio.h>boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));//////PCL
接下来,开始3D显示内部循环。我坐在一个按钮里面了。代码如下:
void CPCLDemoDlg::OnBnClickedButton1()//开始3D显示内部循环。{while (!viewer->wasStopped()){viewer->spinOnce(100);boost::this_thread::sleep(boost::posix_time::microseconds(100000));}}
最后是更新点云,我坐在另一个按钮中了。代码如下:
void CPCLDemoDlg::OnBnClickedButton6()//更新点云{pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>);pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr(new pcl::PointCloud<pcl::PointXYZRGB>);std::cout << "Genarating example point clouds.\n\n";// We're going to make an ellipse extruded along the z-axis. The colour for// the XYZRGB cloud will gradually go from red to green to blue.uint8_t r(255), g(15), b(15);for (float z(-1.0); z <= 1.0; z += 0.05){for (float angle(0.0); angle <= 360.0; angle += 5.0){pcl::PointXYZ basic_point;basic_point.x = 0.5 * cosf(pcl::deg2rad(angle));basic_point.y = sinf(pcl::deg2rad(angle));basic_point.z = z;basic_cloud_ptr->points.push_back(basic_point);pcl::PointXYZRGB point;point.x = basic_point.x;point.y = basic_point.y;point.z = basic_point.z;uint32_t rgb = (static_cast<uint32_t>(r) << 16 |static_cast<uint32_t>(g) << 8 | static_cast<uint32_t>(b));point.rgb = *reinterpret_cast<float*>(&rgb);point_cloud_ptr->points.push_back(point);}if (z < 0.0){r -= 12;g += 12;r = m_colorInc;//g = m_colorInc;}else{g -= 12;b += 12;}}m_colorInc += 10;basic_cloud_ptr->width = (int)basic_cloud_ptr->points.size();basic_cloud_ptr->height = 1;point_cloud_ptr->width = (int)point_cloud_ptr->points.size();point_cloud_ptr->height = 1;viewer->removeAllPointClouds();viewer->removeAllShapes();pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(point_cloud_ptr);viewer->addPointCloud<pcl::PointXYZRGB>(point_cloud_ptr, rgb, "sample cloud");viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");//viewer->addCoordinateSystem(1.0);//显示坐标轴,有时看着碍事。。所以我把他注释掉了。viewer->initCameraParameters();viewer->setBackgroundColor(0, 0, 0);viewer->setCameraPosition(0, 0, -2, 0, -1, 0, 0);}
阅读全文
0 0
- 用PCL刷新显示变化的点云
- PCL点云的显示
- PCL可视化显示点云
- PCL显示点云[微记]
- PCL可视化显示点云
- PCL点云的基本读取和显示
- PCL中计算点云的法向量并显示
- PCL:点云的可视化(程序中在线显示)
- PCL:点云的法线估计(并显示)
- PCL用PCLVisualizer显示点云之窗口黑屏
- PCL 学习笔记-使用 PCL 来显示点云
- PCL+VS2010+Qt显示点云
- pcl点云mfc单文档显示
- PCL+QT+VS显示点云
- KinectV2 qt pcl 实现点云显示
- PCL编程->三维彩色点云显示
- OpenNi2+PCL显示彩色点云
- pcl点云的离群点去除
- 人类已经无法控制的相机:谷歌AI相机Clips解密
- 7. 命令模式
- Python记录日志——在终端输出并保存到本地文件
- js实现自定义事件
- PHP使用QueryList轻松实现一个百度网盘资源搜索引擎
- 用PCL刷新显示变化的点云
- uva 11516
- leetcode 482. License Key Formatting(C语言,标准化密钥)25
- 读深入理解Java虚拟机-3
- 单例模式用法
- 浅谈js里的attributes和与之相关的一些属性
- Pandas基础-DataFrame-增删改查
- bzoj4385 [POI2015]Wilcze doły
- 几种常见的微服务架构方案——ZeroC IceGrid、Spring Cloud、基于消息队列、Docker Swarm