如何在点云中找到对象的质心?

Rob*_*ice 3 c++ point-cloud-library

谁能告诉我如何在点云中找到对象的质心?我还没有尝试过任何代码,因为我不知道如何去做。

unx*_*nut 5

如果您有点位置,您应该能够平均 x 和 y 位置。

int x = 0; y = 0;
for ( i = 0; i < num_pts; i++ )
{
    x += pt[i].x;
    y += pt[i].y;
}
centroid.x = x / num_pts;
centroid.y = y / num_pts;
Run Code Online (Sandbox Code Playgroud)

  • 或者,您可以使用本机 PCL 方法:`pcl::computeCentroid(pointCloud, outCentroid);` (4认同)