您的位置:首页 > 其它

PCL学习笔记(1)---可视化-cloud_viewer

2017-03-30 15:54 417 查看
cloud_viewer.cpp

`#include

#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>


“`

int user_data;

void

viewerOneOff (pcl::visualization::PCLVisualizer& viewer)

{

viewer.setBackgroundColor (1.0, 0.5, 1.0);//设置背景颜色

pcl::PointXYZ o;

o.x = 0;

o.y = 0;

o.z = 0;

viewer.addSphere (o, 1, “sphere”, 0);//添加一个球体

std::cout << “i only run once” << std::endl;

}

void

viewerPsycho (pcl::visualization::PCLVisualizer& viewer)//在可视化对象中添加一个刷新显示字符串

{

static unsigned count = 0;

std::stringstream ss;

ss << “Once per viewer loop: ” << count++;

viewer.removeShape (“text”, 0);

viewer.addText (ss.str(), 200, 300, “text”, 0);

//FIXME: possible race condition here:

user_data++;

}

int

main ()

{

pcl::PointCloud::Ptr cloud (new pcl::PointCloud);

pcl::io::loadPCDFile (“maize.pcd”, *cloud);

pcl::visualization::CloudViewer viewer(“Cloud Viewer”);

//showCloud函数是同步的,在此处等待直到渲染显示为止

viewer.showCloud(cloud);

//该注册函数在可视化时只调用一次

viewer.runOnVisualizationThreadOnce (viewerOneOff);

//该注册函数在渲染输出时每次都调用

viewer.runOnVisualizationThread (viewerPsycho);//用了可视化多线程

while (!viewer.wasStopped ())

{

//在此处可以添加其他处理

user_data++;

}

return 0;

} `

“`


使用vtk可以用快捷键

w:切换到网格渲染 可以把球变成网格形状

s:曲面渲染

j:截图

等具体参看p139页

http://blog.csdn.net/fandq1223/article/details/53186244

http://blog.csdn.net/chentravelling/article/details/43484245
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: