I'm trying to create bounding box around “non ground” objects with PCL and measure its dimensions.
My pipeline looks like this:
Getting XYZ cloud points → Pass Through → Voxel Grid → Statistical outline removal → Euclidean clusterization → Moment of inertia estimation → Some trivial math for getting length, width and height.
But I’m stuck with problem:
As you can see there is an “empty” space between ground and object, because there was no information about “inner” points. Thats why I can’t create proper AABB around my object.
So, my question is: how can I “reconstruct” this surface to create proper AABB around my object? Like its standing on a ground plane and not flying? I’m pretty new in PCL, may be I’m missing something trivial?
Assuming that your objects always stand on a planar ground surface, I'd recommend to approach the problem in the following way. First, find the coefficients of the ground plane. Second, project object points onto this plane to get the "footprint" of your object. Finally, extend your bounding box to include projected points.
The algorithms that you'd need are available in PCL. For plane fitting, check this tutorial. For point projection, use the following snippet:
pcl::ProjectInliers<pcl::PointXYZ> proj;
proj.setModelType (pcl::SACMODEL_PLANE);
proj.setInputCloud (cloud_object);
proj.setModelCoefficients (plane_coefficients);
proj.filter (*cloud_projected);