当前位置:   article > 正文

点云视窗类CloudViewer_“pointclouddialog::vieweroneoff”: 非标准语法;请使用 "&" 来创

“pointclouddialog::vieweroneoff”: 非标准语法;请使用 "&" 来创建指向成员的指
  1. #include <pcl/visualization/cloud_viewer.h>
  2. #include <iostream>
  3. #include <pcl/io/io.h>
  4. #include <pcl/io/pcd_io.h>
  5. int user_data;
  6. void
  7. viewerOneOff(pcl::visualization::PCLVisualizer& viewer)
  8. {
  9. viewer.setBackgroundColor(1.0, 0.5, 1.0);
  10. pcl::PointXYZ o;
  11. o.x = 1.0;
  12. o.y = 0;
  13. o.z = 0;
  14. viewer.addSphere(o, 0.25, "sphere", 0);
  15. std::cout << "i only run once" << std::endl;
  16. }
  17. void
  18. viewerPsycho(pcl::visualization::PCLVisualizer& viewer)
  19. {
  20. static unsigned count = 0;
  21. std::stringstream ss;
  22. ss << "Once per viewer loop: " << count++;
  23. viewer.removeShape("text", 0);
  24. viewer.addText(ss.str(), 200, 300, "text", 0);
  25. //FIXME: possible race condition here:
  26. user_data++;
  27. }
  28. int
  29. main()
  30. {
  31. pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
  32. pcl::io::loadPCDFile("my_point_cloud.pcd", *cloud);
  33. pcl::visualization::CloudViewer viewer("Cloud Viewer");
  34. //blocks until the cloud is actually rendered
  35. viewer.showCloud(cloud);
  36. //use the following functions to get access to the underlying more advanced/powerful
  37. //PCLVisualizer
  38. //This will only get called once
  39. viewer.runOnVisualizationThreadOnce(viewerOneOff);
  40. //This will get called once per visualization iteration
  41. viewer.runOnVisualizationThread(viewerPsycho);
  42. while (!viewer.wasStopped())
  43. {
  44. //you can also do cool processing here
  45. //FIXME: Note that this is running in a separate thread from viewerPsycho
  46. //and you should guard against race conditions yourself...
  47. user_data++;
  48. }
  49. return 0;
  50. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/394194
推荐阅读
相关标签
  

闽ICP备14008679号