pcl icon indicating copy to clipboard operation
pcl copied to clipboard

[filters] FrustumCulling: asymmetrical Field of View

Open roncapat opened this issue 1 year ago • 7 comments

Is your feature request related to a problem? Please describe.

FrustumCulling allows to crop a PointCloud based on horizontal/vertical FoV and plane distance. However, if you decide to crop with a vertical FoV of 30° (as an example), the module allows only to crop symmetrically (+15° over the sight plane and -15° under the sight plane).

Context

I am trying to discard spurious or useless points from Stereo Cameras and Time-of-Flight sensors:

  • imagine to build an autonomous rover, and you need only the shape of the terrain in front of you. You don't want to analyse far away points or flying points at sky level.
  • imagine you have to discard a region on the bottom of your FoV because it sees part of your vehicle (due of how it is mounted).

Expected behavior

Possibility to specify positive and negative FOV boundaries for horizontal and vertical FOV.

Current Behavior

FOV can only be set centered to the central line of sight.

roncapat avatar Sep 12 '22 10:09 roncapat

@roncapat There was a pull request a few months ago that enhanced the functionality of FrustumCulling: https://github.com/PointCloudLibrary/pcl/pull/5136 Can you check whether that can help you achieve what you describe?

mvieth avatar Sep 12 '22 10:09 mvieth

Thank you for pointing out. I already checked, and that feature unfortunately doesn't cover this need, at least directly. Some computations would be needed to exploit ROI selection, but this would be a very indirect way to achieve the task. I'd like to see a method that transparently accepts bounds in degrees. Also, ROI feature is not so well documented.

roncapat avatar Sep 12 '22 10:09 roncapat

I'd like to see a method that transparently accepts bounds in degrees

Can you suggest function declarations, to describe precisely what you have in mind?

Also, ROI feature is not so well documented

What is missing, in your opinion?

mvieth avatar Sep 12 '22 13:09 mvieth

Of course. I would add something like

setHorizontalFOV (float fov_left_bound, float fov_right_bound)
setVerticalFOV (float fov_up_bound, float fov_down_bound)

where bounds can be positive or negative values. Eg. setHorizontalFOV(-10,20) would mean "look from -10 degrees left to 20 degrees right" (a total FOV of 30). Moreover, setHorizontalFOV(-15,15) would be equivalent to the current setHorizontalFOV(30) (which of course can be kept in the API).

It would work without problem even in situations like setHorizontalFOV(10, 20). The resulting FOV would be 20-10=10, but looking slightly on the right, in this example.

roncapat avatar Sep 12 '22 13:09 roncapat

Concerning ROI, it is not clear from documentation whether it is something used in conjunction or disjunction with FOV setting. Looking at the code, ROI is used in conjunction/cascade to FOV cropping (when computing the frustum boundary planes), but their usage is very counterintuitive. I would at least provide an example or a use case where someone gets a ROI from the projected point cloud (depth image) and obtain normalized ROI inputs to use them in FrustumCulling. I would have liked more the disjuncted approach: either set the FOV (angles) or ROI (uniform sensor plane fractions).

roncapat avatar Sep 12 '22 13:09 roncapat

Your suggestions sound good. I will see when I have the time to implement them. Or maybe someone else is interested to add this.

mvieth avatar Sep 18 '22 09:09 mvieth

@roncapat Please have a look at the linked pull request and say if that is what you had in mind

mvieth avatar Sep 20 '22 08:09 mvieth