【问题标题】:Extract Point Cloud from a pcl::people::PersonCluster<PointT>从 pcl::people::Person Cluster<Point> 中提取点云
【发布时间】:2015-05-12 10:54:44
【问题描述】:

我正在为大学做一个项目,我需要提取人们的点云来使用它。我做了一个ROS节点适应教程Ground based rgdb people detection的代码,现在我想在一个主题中发布第一个检测到的集群的点云。

但是我无法提取那个点云,类的定义在这里定义person_cluster.h。还有一个公共成员:

typedef pcl::PointCloud<PointT> PointCloud;

所以要将其转换为 sensor_msgs::PointCloud2 我愿意:

pcl_conversions::fromPCL(clusters.at(0).PointCloud,person_msg);

其中person_msgPointCLoud2 消息,clusterspcl::people::PersonCluster&lt;PointT&gt; 的向量,我只想发布第一个点云,因为我假设场景中只有一个人。

编译器给了我这个错误:

错误:无效使用 ‘pcl::people::PersonCluster::PointCloud’ pcl_conversions::fromPCL(clusters.at(0).PointCloud,person_msg);

我对 C++ 了解不多,也无法克服这个错误。谷歌搜索该错误似乎是当您没有“定义”好一个类时出现的,但我怀疑在 pcl 库中他们定义了一个错误的类。

【问题讨论】:

    标签: c++ detection point-cloud-library


    【解决方案1】:

    对于那些感兴趣的人,我解决了我的问题。

    在 pcl 的论坛中,我找到了一个 post,我使用的人员检测器的开发人员给出了答案。 所以基本上:

    // Get cloud after voxeling and ground plane removal:
          PointCloudT::Ptr no_ground_cloud (new PointCloudT);
          no_ground_cloud = people_detector.getNoGroundCloud();
    
          // Show pointclouds of every person cluster:
          PointCloudT::Ptr cluster_cloud (new PointCloudT);
          for(std::vector<pcl::people::PersonCluster<PointT> >::iterator it = clusters.begin(); it != clusters.end(); ++it)
          {
            if (it->getPersonConfidence() > min_confidence)
            {
              // Create the pointcloud with points belonging to the current cluster:
              cluster_cloud->clear();
              pcl::PointIndices clusterIndices = it->getIndices();    // cluster indices
              std::vector<int> indices = clusterIndices.indices;
              for(unsigned int i = 0; i < indices.size(); i++)        // fill cluster cloud
              {
                PointT* p = &no_ground_cloud->points[indices[i]];
                cluster_cloud->push_back(*p);
              }
    
              // Visualization:
              viewer.removeAllPointClouds();
              viewer.removeAllShapes();
              pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb(cluster_cloud);
              viewer.addPointCloud<PointT> (cluster_cloud, rgb, "cluster_cloud");
              viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "cluster_cloud");
              viewer.spinOnce(500);
            }
          }
    

    实际上,我无法在传感器消息 PointCloud2 中转换这种类型的点云,甚至尝试在 pcl::PointCloud&lt;pcl::PointXYZ&gt; 中转换该点云。

    一个可行的解决方案是使用 cluster_cloud 类型的 pcl::PointCloud&lt;pcl::PointXYZ&gt; 然后使用类型的发布者 pcl::PointCloud&lt;pcl::PointXYZ&gt; 如:

    ros::Publisher person_pub = nh.advertise<PointCloud>("personPointCloud", 1000);
    

    无论如何,它没有发布任何东西,rviz 没有显示任何东西。但是 viever 正在显示被检测到的人的点云。由于那个点云不是我所期望的(如果你移动手臂,算法不会给你所有的手臂)它对我的项目没有用,所以我放弃了它。

    所以仍然是在ros中发布它的问题,但是获取pointcloud的问题已经解决了。

    【讨论】:

      猜你喜欢
      • 2021-07-31
      • 2018-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多