【问题标题】:pcl use of shared pointers, does it make copies?pcl 使用共享指针,它会复制吗?
【发布时间】:2014-06-12 19:13:56
【问题描述】:

所以我一直在使用pcl SampleConsensus 模块进行一些线拟合,我发现pcl 点云的使用非常奇怪。我目前正在寻找最突出的线,然后我只从云中检索异常值并再次对其进行搜索。

所以要在云上执行 ransac 说我有一些设置:

pcl::PointCloud<pcl::PointXYZ>::Ptr dataCloud(shared_ptr_cloud_from_elsewhere);
pcl::PointCloud<pcl::PointXYZ>::Ptr outlierCloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::SampleConsensusModelLine<pcl::PointXYZ>::Ptr modelLine(
    new pcl::SampleConsensusModelLine<pcl::PointXYZ>(dataCloud));

//Pay careful attention to line below because its position determines 
//if the code is going to work or not
pcl::SampleConsensusModelLine<pcl::PointXYZ>::Ptr modelLine2(
    new pcl::SampleConsensusModelLine<pcl::PointXYZ>(outlierCloud));

pcl::RandomSampleConsensus<pcl::PointXYZ> ransac(modelLine);
ransac.compute();
ransac.inliers(inliers);

使用ExtractIndices,我从内点列表的负值中检索异常值,并将它们放入outlierCloudoutlierCloud 已检查并且肯定有分数。然后我要做的就是更改ransac 正在使用的模型并重新开始:

ransac.setSampleConsensusModel(modelLine2)
ransac.compute(); //This will fail, due to having no points.

所以ransac.compute() 失败了,但是为什么呢? modelLine2 已定义并有一个指向云outlierCloud 的指针,它肯定有积分?

所以我说要注意的那一行,如果你移动它以便在填写outlierCloud 之后定义modelLine2,那么它就可以正常工作。同样的例子同样的一切。

这向我表明pcl 正在获取此云的深层副本,即使它请求指向它的共享指针?这不是很糟糕吗?我的范围没有变化或发生任何有趣的事情,那么为什么我必须在数据填充到云端后创建modelLine2

【问题讨论】:

    标签: c++ shared-ptr point-cloud-library


    【解决方案1】:

    没有进行深度复制,但 SampleConsusModel 的 constructor 在内部调用其 setInputCloud 方法,该方法存储(如预期的那样)指向云的指针并调整索引集的大小到使用云的 当前 大小(在您的情况下为 0)。所以指针是正确的,但模型使用0 索引来表示它指向的云。

    作为一种解决方法,您可以在 outlierCloud 被填满后自己致电 setInputCloud

    【讨论】:

      猜你喜欢
      • 2020-10-15
      • 2011-05-25
      • 2018-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-14
      • 2020-09-10
      • 2013-11-28
      相关资源
      最近更新 更多