Ask Your Question
0

How to use CropBox on PointCloud2

asked 2019-03-11 03:12:29 -0500

S.Yildiz gravatar image

I have a tof camera with the type PointCloud2. I have looked a bit and found the cropbox function. I am a beginner in ros and I don't know how to use it. I found this code:

pcl::CropBox<pcl::PointXYZRGBA> boxFilter;
boxFilter.setMin(Eigen::Vector4f(minX, minY, minZ, 1.0));
boxFilter.setMax(Eigen::Vector4f(maxX, maxY, maxZ, 1.0));
boxFilter.setInputCloud(body);
boxFilter.filter(*bodyFiltered);

But now I don't know further. I have also seen this code:

int main (int argc, char** argv)
{
    pcl::visualization::PCLVisualizer viewer("Cloud Viewer");

    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr body (new pcl::PointCloud<pcl::PointXYZRGBA>);
    pcl::io::loadPCDFile ("body.pcd", *body);

    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr bodyFiltered (new pcl::PointCloud<pcl::PointXYZRGBA>);

    pcl::PassThrough<pcl::PointXYZRGBA> filter;
    filter.setInputCloud (body);
    filter.setFilterFieldName ("x");
    filter.setFilterLimits (minX, maxX);
    filter.setFilterFieldName ("y");
    filter.setFilterLimits (minY, maxY);
    filter.setFilterFieldName ("z");
    filter.setFilterLimits (minZ, maxZ);
    filter.filter (*bodyFiltered);

    viewer.addPointCloud (bodyFiltered,"body");
    viewer.spin();
    return 0;
}

Do I just have to replace the part with filter. ?

And I also want that the box is rotating with the imu. Would it be enough to set this box as a child of the imu?

And do I have to do a remap?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-23 10:51:09 -0500

You can always check about the examples in the test code of PCL official library. Here is the code introduce how to use the filter: cropBox filter

And here is the code:

  // Test the PointCloud<PointT> method
 CropBox<PointXYZ> cropBoxFilter (true);
 cropBoxFilter.setInputCloud (input);
 Eigen::Vector4f min_pt (-1.0f, -1.0f, -1.0f, 1.0f);
 Eigen::Vector4f max_pt (1.0f, 1.0f, 1.0f, 1.0f);

 // Cropbox slighlty bigger then bounding box of points
 cropBoxFilter.setMin (min_pt);
 cropBoxFilter.setMax (max_pt);

 // Indices
 vector<int> indices;
 cropBoxFilter.filter (indices);

 // Cloud
 PointCloud<PointXYZ> cloud_out;
 cropBoxFilter.filter (cloud_out);
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-03-11 03:12:29 -0500

Seen: 660 times

Last updated: Mar 11 '19