pcl icon indicating copy to clipboard operation
pcl copied to clipboard

ExtractPolygonalPrismData & ConcaveHull yeild wrong results

Open yoavmil opened this issue 3 years ago • 2 comments

tl;dr If the concave hull is made of multiple polygons, when the prism checks if a point is inside, the result is sometimes wrong. I also have the solution.

To test it, I made a cloud of 2 rings, found there concave hull, and applied ExtractPolygonalPrismData on them.

before fix: image

after fix: image

To Reproduce I've put a working code in my github

pcl:x64-windows 1.12.0#4

Possible Solution I've written and tested a solution. But first I'll explain the bug. each point is tested if it is inside a polygon using this code. image The problem is that if there is more than one ring in the polyongs, the code flattens them to one polygons, adding more segments that doesn't exist.

To solve this, I took the polygons from ConcaveHull, which discribe the rings and their order, and passed it to ExtractPolygonalPrismData::segment. Then, I added an overload to isXYPointIn2DXYPolygon that recieved the rings order as well, and check each of them seperatly.

The code is also in my repo.

I could do a PR if someone would read and aprove.

yoavmil avatar Feb 10 '22 17:02 yoavmil

Please go ahead and make a PR and also a unit test that verifies the result, to avoid future bugs.

larshg avatar Feb 10 '22 19:02 larshg

https://github.com/PointCloudLibrary/pcl/pull/5168 @larshg review and approve please

yoavmil avatar Feb 13 '22 11:02 yoavmil