zoukankan      html  css  js  c++  java
  • PCL:PCL可视化显示点云

    (1):引用:仅仅是简单的显示点云,可以使用CloudViewer类。这个类非常简单易用。但要注意,它不是线程安全的。如果要用于多线程,还要参考PCLVisualizer。

    需要注意的是,PointCloud的数据类型要和PCD文件中或者代码中的PointT一致!

    并且:CloudViewer除了显示什么也不能干.

     显示代码为:

    pcl::visualization::CloudViewer viewer ("Cluster viewer");
     viewer.showCloud(colored_cloud);
      while (!viewer.wasStopped ())
      {
      }

    (2):PCLVisualizer详细使用规则

     简单函数解释:
    
    boost::shared_ptr<pcl::visualization::PCLVisualizer> simpleVis (pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud)
    {
      // --------------------------------------------
      // -----Open 3D viewer and add point cloud-----
      // --------------------------------------------
    
      boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));  
      viewer->setBackgroundColor (0, 0, 0);  
      viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");  
      viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");  
      viewer->addCoordinateSystem (1.0);  
      viewer->initCameraParameters ();
    
      return (viewer);
    }
    
    
    鼠标事件:
    
    void mouseEventOccurred (const pcl::visualization::MouseEvent &event,
                         void* viewer_void)
    {
      boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
      if (event.getButton () == pcl::visualization::MouseEvent::LeftButton && event.getType () == pcl::visualization::MouseEvent::MouseButtonRelease)
      {
        std::cout << "Left mouse button released at position (" << event.getX () << ", " << event.getY () << ")" << std::endl;
        char str[512];
    
        sprintf (str, "text#%03d", text_id ++);
        viewer->addText ("clicked here", event.getX (), event.getY (), str);
      }
    }
    
    
    键盘交互:
    void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
                            void* viewer_void)
    {
      boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
      if (event.getKeySym () == "r" && event.keyDown ())
      {
        std::cout << "r was pressed => removing all text" << std::endl;
    
        char str[512];
        for (unsigned int i = 0; i < text_id; ++i)
        {
          sprintf (str, "text#%03d", i);
          viewer->removeShape (str);
        }
        text_id = 0;
      }
    }
    
    
    调用函数为:
    viewer->registerKeyboardCallback (keyboardEventOccurred, (void*)&viewer);
    viewer->registerMouseCallback (mouseEventOccurred, (void*)&viewer);
    摄像头初始化函数:

    boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
    viewer->initCameraParameters ();

    后记:

           具体的使用方法还有很多,参见官方文档。

  • 相关阅读:
    fiddler 增加请求时间显示
    es 多字段分词查询优化
    【二分】【预处理】zoj4029 Now Loading!!!
    【数论】【扩展欧几里得】Codeforces Round #484 (Div. 2) E. Billiard
    【set】【multiset】Codeforces Round #484 (Div. 2) D. Shark
    【推导】Codeforces Round #484 (Div. 2) C. Cut 'em all!
    【递推】Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!] D. XOR-pyramid
    【数论】Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!] C. Finite or not?
    【Trie】【枚举约数】Codeforces Round #482 (Div. 2) D. Kuro and GCD and XOR and SUM
    【枚举】【贪心】Codeforces Round #482 (Div. 2) B. Treasure Hunt
  • 原文地址:https://www.cnblogs.com/wishchin/p/9200369.html
Copyright © 2011-2022 走看看