You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
getCentroidIndexAt in voxel_grid.h deliver wrong leaf_layout_[idx] #3529
inline int
getCentroidIndexAt (const Eigen::Vector3i &ijk) const
{
int idx = ((Eigen::Vector4i() << ijk, 0).finished() - min_b_).dot (divb_mul_);
if (idx < 0 || idx >= static_cast<int> (leaf_layout_.size ())) // this checks also if leaf_layout_.size () == 0 i.e. everything was computed as needed
{
//if (verbose)
// PCL_ERROR ("[pcl::%s::getCentroidIndexAt] Specified coordinate is outside grid bounds, or leaf layout is not saved, make sure to call setSaveLeafLayout(true) and filter(output) first!\n", getClassName ().c_str ());
return (-1);
}
return (leaf_layout_[idx]);
}
If you retrieve points out of voxel grids, and let's see its ijk[0] is large, you will get a index with wrong number rather than -1, due to its use of idx.
Solution
Directly check ijk, add following code to getCentroidIndexAt function:
if (ijk[0]<min_b_[0] || ijk[0]>max_b_[0] || ijk[1]<min_b_[1] ||
ijk[1]> max_b_[1] || ijk[2]<min_b_[2] || ijk[2]>max_b_[2]) return (-1);
@nilsgr I checked voxel_grid_occlusion_estimation.hpp, and getCentroidIndexAt is used in three places: one, two, three
But in all three places, the for/while loops make sure that the values passed to getCentroidIndexAt are okay with respect to min_b_ and max_b_. Can you say which values min_b_ and max_b_ have in your case?
Activity
stale commentedon May 19, 2020
Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.
nilsgr commentedon Jan 4, 2023
I can confirm this bug. It caused random artifacts using voxel_grid_occlusion_estimation.hpp... The provided solution fixed it for me.
mvieth commentedon Jan 9, 2023
@nilsgr I checked voxel_grid_occlusion_estimation.hpp, and
getCentroidIndexAtis used in three places: one, two, threeBut in all three places, the for/while loops make sure that the values passed to
getCentroidIndexAtare okay with respect to min_b_ and max_b_. Can you say which values min_b_ and max_b_ have in your case?