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;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章