Ejemplo n.º 1
0
void
compute (const pcl::PCLPointCloud2::ConstPtr &input, pcl::PCLPointCloud2 &output,
         double radius)
{
  // Convert data to PointCloud<T>
  PointCloud<PointXYZ>::Ptr xyz (new PointCloud<PointXYZ>);
  fromPCLPointCloud2 (*input, *xyz);

  // Estimate
  TicToc tt;
  tt.tic ();
  
  print_highlight (stderr, "Computing ");

  UniformSampling<PointXYZ> us;
  us.setInputCloud (xyz);
  us.setRadiusSearch (radius);
  PointCloud<PointXYZ> output_;
  us.filter (output_);

  print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%d", output_.size()); print_info (" points]\n");

  // Convert data back
  toPCLPointCloud2 (output_, output);
}
Ejemplo n.º 2
0
    void
    UniformSamplingWrapper::compute(PointCloudInPtr input, PointCloudOut &output)
    {
      float keypoint_separation = 0.01f;

      IndicesPtr indices (new std::vector<int>());
      PointCloud<int> leaves;
      UniformSampling<PointNormal> us;
      us.setRadiusSearch(keypoint_separation);
      us.setInputCloud(input);
      us.compute(leaves);

      // Copy point cloud and return
      indices->assign(leaves.points.begin(), leaves.points.end()); // can't use operator=, probably because of different allocators
      copyPointCloud(*input, *indices, output);
    }