pcl_show


    using showView = pcl::visualization::PCLVisualizer;
	showView viewer("PCL");
	viewer.setBackgroundColor(0, 0, 0);
	viewer.addPointCloud(cloud);
	while (!viewer.wasStopped())
		viewer.spinOnce();
int user_data;
void viewerOneOff(pcl::visualization::PCLVisualizer& viewer)
{
	viewer.setBackgroundColor(1.0, 0.5, 1.0);//设置背景颜色
	pcl::PointXYZ o;//存储球心的位置
	o.x = 1.0;
	o.y = 0;
	o.z = 0;

	viewer.addSphere(o, 0.25, "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()
{
	using pointT = pcl::PointCloud<pcl::PointXYZ>;
	pointT::Ptr cloud(new pointT);

	pcl::io::loadPCDFile("C:/Users/BZL/Desktop/rs1.pcd", *cloud);

	pcl::visualization::CloudViewer viewer("Cloud Viewer");
	
	//该注册函数在可视化时只调用一次
	//viewer.runOnVisualizationThreadOnce(viewerOneOff);

	//该注册函数在渲染输出时每次都调用
	viewer.runOnVisualizationThread(viewerPsycho);

	//showCloud函数是同步的,在此处等待直到渲染显示为止
	viewer.showCloud(cloud);
	while (!viewer.wasStopped())
	{
		//在此处可以添加其他处理
		
		user_data++;
	}
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值