Reduce time taken in CropHull by using O(n) pre-filtering with CropBox#3883
Reduce time taken in CropHull by using O(n) pre-filtering with CropBox#3883DaniilSNikulin wants to merge 24 commits intoPointCloudLibrary:masterfrom
CropHull by using O(n) pre-filtering with CropBox#3883Conversation
…udLibrary#1657) * funciton applyFilter didn't clear output data before start adding new point or indices * issue PointCloudLibrary#1657: CropHull 3d not cropping inside. [decision](piaggiofastforward@b8a8a2b)
suggestions `resize(0)` -> `clear` from @kunaltyagi Co-Authored-By: Kunal Tyagi <tyagi.kunal@live.com>
CropHull by using O(n) pre-filtering with CropBox
… expect extract_removed_indices==true
* delete unused coments of code (2 lines) * delete applyFilter[23]D(PointCloud) -- private and not used * delete applyFilter(PointCloud) -- FilterIndices already have got * implementation * deleted applyFilter fix bug: FilterIndices funtionality for * keepOrganized cloud was missed in original implementation * set extract_removed_indices default to true and support * removed_indices functionality * perfomance testing: PCL.ConvexHull_2dsquare w/o CrobBox spent 76ms, * w/ spent 28ms; PCL.ConvexHull_3dcube w/o CropBox spent 1034ms, w/ * spent 640ms
|
Just a reminder to remember to try to keep these PRs as atomic as possible. Avoid the urge to fix the internals of the class unless the PR is all about that. As an example: I would split this PR with its original intent, 1 PR for fixing the original bug, another to change CropHull to prefilter with CropBox. Just keep those things in mind before venturing into optimizing the internals. |
bug was founded by @Morwenn also tests was modified to detect this bug
Co-Authored-By: Kunal Tyagi <tyagi.kunal@live.com>
…keelInside = crop_outside_ ^ negative_
…thub.com/DaniilSNikulin/pcl into issue_3875_using_CropBox_inside_CropHull
kunaltyagi
left a comment
There was a problem hiding this comment.
The tests can be rewritten to be more maintainable.
test/filters/test_crop_hull.cpp
Outdated
|
|
||
| cropHullFilter.setHullIndices(hullPolygons); | ||
| cropHullFilter.setHullCloud(hullPoints); | ||
| //cropHullFilter.setDim(2); // if you uncomment this, it will work |
| pcl::Indices filteredIndices; | ||
| cropHullFilter.filter(filteredIndices); | ||
| pcl::test::EXPECT_EQ_VECTORS(testData.insideIndices, filteredIndices); | ||
| cropHullFilter.filter(filteredIndices); |
There was a problem hiding this comment.
Seems to be duplicated check wrt 2 lines before
There was a problem hiding this comment.
this test check reentrancy of function filter. results should not depend on amount of calls before.
PS: maybe I'm not correct use termin of reentrancy and it must rename to repeatability
| pcl::Indices filteredIndices; | ||
| cropHullFilter.filter(filteredIndices); | ||
| pcl::test::EXPECT_EQ_VECTORS(testData.insideIndices, filteredIndices); | ||
| cropHullFilter.filter(filteredIndices); |
| for (std::size_t index = 0; index < indices_->size (); index++) | ||
| const bool keepInside = crop_outside_ ^ negative_; | ||
|
|
||
| pcl::Indices cropInlierIndices; |
There was a problem hiding this comment.
Let's add a note here why we're doing this since this is the core contribution of the PR.
Firstly reason for PR was only issue #3875: add CropBox inside CropHull for increasing performance.
In progress was founded and fixed some bugs:
point or indices.
Added unit tests for CropHull. (only ConvexHull case).
Also was deleted some duplicated code. Implementation for cloud and indices filtering was equals, but duplicates.
resolve #1657
resolve #3541
resolve #3960
UPD:
CropHull::applyFilter[23]D(PointCloud)-- private and not usedCropHull::applyFilter(PointCloud)--FilterIndices::applyFilter(PointCloud)already have got implementationCropHull::applyFilterfix bug:FilterIndicesfuntionality forkeepOrganizedcloud was missed in original implementation