opencv/modules/imgproc
Pierre Chatelier d83df66ff0
Merge pull request #26834 from chacha21:findContours_speedup
Find contours speedup #26834

It is an attempt, as suggested by #26775, to restore lost speed when migrating `findContours()` implementation from C to C++

The patch adds an "Arena" (a pool) of pre-allocated memory so that contours points (and TreeNodes) can be picked from the Arena.
The code of `findContours()` is mostly unchanged, the arena usage being implicit through a utility class Arena::Item that provides C++ overloaded operators and construct/destruct logic.

As mentioned in #26775, the contour points are allocated and released in order, and can be represented by ranges of indices in their arena. No range subset will be released and drill a hole, that's why the internal representation as a range of indices makes sense.

The TreeNodes use another Arena class that does not comply to that range logic.

Currently, there is a significant improvement of the run-time on the test mentioned in #26775, but it is still far from the `findContours_legacy()` performance.


- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [X] The PR is proposed to the proper branch
- [X] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2025-03-12 18:00:01 +03:00
..
doc Merge pull request #25616 from savuor:rv/yuv_docs 2024-05-25 13:12:03 +03:00
include/opencv2 Merge pull request #26842 from chacha21:threshold_with_mask 2025-03-12 17:55:07 +03:00
misc add some functions and tests 2024-12-01 23:17:35 +03:00
perf Remove useless C headers 2025-01-13 16:34:28 +01:00
src Merge pull request #26834 from chacha21:findContours_speedup 2025-03-12 18:00:01 +03:00
test Merge pull request #26842 from chacha21:threshold_with_mask 2025-03-12 17:55:07 +03:00
CMakeLists.txt fix FFmpeg wrapper build 2024-12-26 12:15:46 +00:00