Custom filter (box) for pointclouds
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);
}
));
}