-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Reduce time taken in CropHull
by using O(n)
pre-filtering with CropBox
#3883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Reduce time taken in CropHull
by using O(n)
pre-filtering with CropBox
#3883
Conversation
…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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this comment for?
pcl::Indices filteredIndices; | ||
cropHullFilter.filter(filteredIndices); | ||
pcl::test::EXPECT_EQ_VECTORS(testData.insideIndices, filteredIndices); | ||
cropHullFilter.filter(filteredIndices); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be duplicated check wrt 2 lines before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pure function?
pcl::Indices filteredIndices; | ||
cropHullFilter.filter(filteredIndices); | ||
pcl::test::EXPECT_EQ_VECTORS(testData.insideIndices, filteredIndices); | ||
cropHullFilter.filter(filteredIndices); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pure function?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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::applyFilter
fix bug:FilterIndices
funtionality forkeepOrganized
cloud was missed in original implementation