pcl中快速深拷贝点云的方式

  • Post author:
  • Post category:其他


template <typename PointInT, typename PointOutT> void
copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
                pcl::PointCloud<PointOutT> &cloud_out)
{
  // Allocate enough space and copy the basics
  cloud_out.header   = cloud_in.header;
  cloud_out.width    = cloud_in.width;
  cloud_out.height   = cloud_in.height;
  cloud_out.is_dense = cloud_in.is_dense;
  cloud_out.sensor_orientation_ = cloud_in.sensor_orientation_;
  cloud_out.sensor_origin_ = cloud_in.sensor_origin_;
  cloud_out.points.resize (cloud_in.size ());

  if (cloud_in.points.empty ())
    return;

  if (isSamePointType<PointInT, PointOutT> ())
    // Copy the whole memory block
    memcpy (&cloud_out[0], &cloud_in[0], cloud_in.size () * sizeof (PointInT));
  else
    // Iterate over each point
    for (std::size_t i = 0; i < cloud_in.size (); ++i)
      copyPoint (cloud_in[i], cloud_out[i]);
}



版权声明:本文为weixin_42295969原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。