Add optimized get_darkest_area implementation #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Looking at the timing breakdown, it seems like get_darkest_area takes the most time, ~67% of the total frame time.
When the imageSkipSize and searchArea are equal, and the searchArea is a clean multiple of internalSkipSize, numpy can be used relatively easily to accelerate the loops. On my pi3, this improved performance of this function by ~10x, ~22ms to ~2.3ms. Overall frame time dropped from ~32ms to ~13ms. This may not scale the same on newer pi's, but the numpy acceleration should still be a sizeable improvement.
I can clean up this pr if this is interesting. Technically this implementation has limitations to the parameters, but I think it should be possible to generalize the design.