使用PCL在点云中进行球体检测

时间:2018-01-31 14:32:20

标签: c++ point-cloud-library point-clouds

我抓住了一个场景的点云,其中一个球安装在机器人手臂上。球是刚性的,直径约为150毫米。以下是Point Cloud的屏幕截图 -

enter image description here

为了跟踪球(上面的截图中的橙色),我尝试使用Sample Consensus Initial Alignment(SAC-IA)算法,因此我首先制作了一个模板,这是使用以下代码的球的点云 -

typedef pcl::PointXYZRGB Point;
typedef pcl::PointCloud<Point> PointCloud;

PointCloud sphere;

float r = 0.075; // in meters
for(float phi = 0;  phi < 2* M_PI; phi+=0.01)
{
  float z = r * cos(phi);
  for(float th = 0;  th < M_PI; th+=0.01)
  {
    float x = r * sin(phi) * cos(th);
    float y = r * sin(phi) * sin(th);

    Point point;
    point.x = x; point.y = y; point.z = z;  // position
    point.b = 51; point.g = 87; point.r = 255; // color

    sphere.push_back(point);
  }
}
sphere.is_dense = true;
sphere.height = 1;
sphere.width = sphere.points.size();

然后使用official PCL website here中提供的代码将模板与点云匹配。我没有把代码放在这里,因为它太长了(大约300行)。

下面是检测的屏幕截图,其中我在检测到的位置绘制了一个绿色球体 -

enter image description here

显然,球检测失败。以下是我的疑问 -

  1. 如何让它运作?有没有对参数进行微调?
  2. PCL中是否有更好的球体检测方法?

0 个答案:

没有答案