Skip to content
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

[surface] Reduce time taken in TextureMapping::sortFacesByCamera from O(faces*points) to O(faces) #3981

Merged
merged 6 commits into from
May 6, 2020

Conversation

langeroo
Copy link
Contributor

For large meshes, the old code was prohibitively slow, and had a TODO to address that. Changing from a vector to an unordered_set reduces the outer loop's complexity from O(N*M) to O(N) where N is the number of faces in a mesh and M is the number of points in the point cloud.

On the sample mesh I was using, I reduced the processing time for 3 test images from over 20 minutes to under 2.

@kunaltyagi kunaltyagi added changelog: enhancement Meta-information for changelog generation module: surface needs: more work Specify why not closed/merged yet labels Apr 28, 2020
@kunaltyagi kunaltyagi changed the title Changed the data structure for how to iterate through occluded points. [surface] Reduce time taken in texture_mapping using unordered_set Apr 28, 2020
@kunaltyagi kunaltyagi changed the title [surface] Reduce time taken in texture_mapping using unordered_set [surface] Reduce time taken in TextureMapping::sortFacesByCamera from O(faces*points) to O(faces) Apr 28, 2020
Copy link
Member

@kunaltyagi kunaltyagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for this PR. Other clean-up in future

Minor: [&] could have been used in the lambda, some comment cleanup (for and around the lambda)

@kunaltyagi kunaltyagi added needs: code review Specify why not closed/merged yet and removed needs: more work Specify why not closed/merged yet labels Apr 29, 2020
@Morwenn
Copy link
Contributor

Morwenn commented Apr 29, 2020

I didn't look at the lambda but indeed: currently every capture is copied into the lambda, which looks needlessly expensive here. If I'm not mistaken it's even copied at each iteration.

@langeroo
Copy link
Contributor Author

I didn't look at the lambda but indeed: currently every capture is copied into the lambda, which looks needlessly expensive here. If I'm not mistaken it's even copied at each iteration.

@kunaltyagi @Morwenn Just committed again. I had errors compiling at first with the [&] but that has been fixed. I've changed it back to [&] now and it works. Thanks for the corrections!

@kunaltyagi kunaltyagi added this to the pcl-1.11.0 milestone May 4, 2020
@kunaltyagi
Copy link
Member

Please rebase so we can test on the now working Mac and Ubuntu 20.04 CI

… to be an unordered set. Previously, the system was checking through a vector in O(n), but now it's going much faster at approximately O(1).
… errors led me to believe that I needed to list all captures, but now that those other errors have been ironed out, @kunaltyagi and @Morwenn have pointed out that that was unnecessary and is in fact computationally wasteful.
@kunaltyagi
Copy link
Member

@SergioRAgostinho

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply the following suggestions and if CI goes green go ahead and merge.

surface/include/pcl/surface/impl/texture_mapping.hpp Outdated Show resolved Hide resolved
@SergioRAgostinho SergioRAgostinho added needs: author reply Specify why not closed/merged yet and removed needs: code review Specify why not closed/merged yet labels May 6, 2020
kunaltyagi and others added 2 commits May 6, 2020 16:42
Going around @langeroo due to release schedule (1/2)

Co-authored-by: Sérgio Agostinho <sergio.r.agostinho@gmail.com>
Going around @langeroo due to release schedule (1/2)

Co-authored-by: Sérgio Agostinho <sergio.r.agostinho@gmail.com>
@kunaltyagi kunaltyagi removed the needs: author reply Specify why not closed/merged yet label May 6, 2020
@kunaltyagi
Copy link
Member

Note: squash and merge

@kunaltyagi kunaltyagi added the needs: testing Specify why not closed/merged yet label May 6, 2020
@kunaltyagi kunaltyagi merged commit 5b09130 into PointCloudLibrary:master May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: enhancement Meta-information for changelog generation module: surface needs: testing Specify why not closed/merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants