Ask Your Question
1

Custom filter (box) for pointclouds

asked 2018-08-07 07:10:32 -0600

Mikhail K. gravatar image

I need to cut out a box (basically reimplement pcl::CropBox link), but with the following code and the pcl::CropBox itself I do not see any difference between the source and the output clouds. Am I doing something wrong? I'm sure that there should be points within the specified min and max box boundaries.

auto const min = Eigen::Vector4f(-0.05702, -0.004205, 4.226287, 1.0);
auto const max = Eigen::Vector4f(0.0, 0.0, 0.0, 1.0);

bool check_point(pcl::PointXYZ const& point)
{
    if (!pcl::isFinite(point))
    {
        return true;
    }

    return (point.x < min[0] || point.y < min[1] || point.z < min[2]) ||
        (point.x > max[0] || point.y > max[1] || point.z > max[2]);
}

void box_filter(pcl::PointCloud<pcl::PointXYZ>::Ptr const& cloud)
{
    cloud->erase(std::remove_if(
        cloud->begin(),
        cloud->end(),
        [](auto const& x)
        {
            return check_point(x);
        }
        ));
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-08-09 23:13:51 -0600

Mikhail K. gravatar image

Apparently erase function has another definition

    cloud->erase(std::remove_if(
        cloud->begin(),
        cloud->end(),
        [&c](auto const& x)
        {
            return check_point(x);
        }), cloud->end());
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

2 followers

Stats

Asked: 2018-08-07 07:10:32 -0600

Seen: 89 times

Last updated: Aug 09 '18