【发布时间】: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,我从内点列表的负值中检索异常值,并将它们放入outlierCloud。 outlierCloud 已检查并且肯定有分数。然后我要做的就是更改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