使用已知模型系数在pcl中绘制多条线

时间:2015-08-11 16:23:55

标签: c++ lines point-cloud-library coefficients

我从点云中提取了片段,并使用pcl::SACSegmentation<pcl::PointXYZ> seg;同时适合所有行。我的所有文件段都存储在同一个文件夹中,我可以逐个读取它们并分别计算它们的模型系数。

解决此问题的最佳方法是通过for循环,但viewer.addLine在第二次迭代时出错,说明在绘制一行后已使用addLine(RANSAC) )。我使用了PCL网站http://pointclouds.org/documentation/tutorials/cylinder_segmentation.php中的方法来确定我所有细分的系数。根据我到目前为止所学到的,模型系数存储在内部。

目标:使用RANSAC同时从模型系数中绘制所有线条,并将它们添加到PCL可视化工具中。

这是我用来加载所有文件的代码段(例子)

std::stringstream ss;
ss << "./cloud_cluster_" << j << ".pcd";
reader.read<pcl::PointXYZ> (ss.str (), *cloud_cluster, false); 
j++;

// snip

pcl::visualizer viewer ("Sample programme")
viewer.addCloud();
viewer.addLine(model_coefficients)

我们将不胜感激。

1 个答案:

答案 0 :(得分:1)

您正在使用的addLine函数在此处记录在API中: http://docs.pointclouds.org/trunk/classpcl_1_1visualization_1_1_p_c_l_visualizer.html#a5fd2b99b85da61df8b58980bdb6b0f41

签名:

bool addLine (const pcl::ModelCoefficients &coefficients, const std::string &id="line", int viewport=0)

在这里你可以看到,当你添加一行时,会自动给它一个字符串id&#34; line&#34;。如果只添加一行,但是对于多行,则需要为每行提供唯一的ID。

e.g。

std::stringstream ss;
ss<<"line"<<j;
viewer.addLine(model_coefficients,ss.str());