-
-
Notifications
You must be signed in to change notification settings - Fork 828
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
[sfm] Performance improvements: optimize RemoveOutliers_AngleError #841
[sfm] Performance improvements: optimize RemoveOutliers_AngleError #841
Conversation
- Use greedy hueristic to avoid O(N^2) code in vast majority of cases - Use Eigen matrix operations to speed up O(N^2) operations - Add omp parallel
Hi @0xfaded, |
Hi Fabien. For large datasets, in my case over 8000 images, this reduces the SFM time from 1h40 to 50 minutes on my machine. This check is run on every feature after every bundle adjustment, so for datasets with large tracks this routine actually becomes the bottleneck. In terms of the actual implementation, every effort is made to exit the loop as early as possible. In most cases, this reduces the expexted complexity from O(N^2) to near O(1). For small datasets, this will not be noticeable. Is there a particular benchmark you want me to run? |
Wow that sounds amazing! |
When we use the local BA, we may retrieve the cameras that have been optimized in the BA (local BA state per pose) and for each camera we have a pre-computed list of tracks id visible in this camera (_map_tracksPerView). |
Thanks @fabiencastan for the suggestion. However I'd prefer to implement this as a separate pull request. |
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.
Thanks for the nice contribution!
I just left some minor syntactical fixes to be more uniform to the code style
Co-authored-by: Simone Gasparini <[email protected]>
CI error on windows:
|
@0xfaded Thanks for the nice work! |
Description
This diff removes an N^2 loop which becomes relevant when processing large numbers of images. On my setup, when processing 8000 images 50% of the time is spent in this routine.
Features list
Implementation remarks
The loop in question searches for the largest angle between view directions. In my implementation, I first attempt a simple greedy algorithm which in almost all cases exits in sub-linear time if the angle exists. If the greedy algorithm fails, I revert to a n^2 implemented in Eigen for speed..
I haven't done a thorough analysis, but I suspect the overall expected runtime is << linear.