opencv/modules/imgproc
Maksim Shabunin a25132986a
Merge pull request #25146 from mshabunin:cpp-contours
Reworked findContours to reduce C-API usage #25146

What is done:
* rewritten `findContours` and `icvApproximateChainTC89` using C++ data structures
* extracted LINK_RUNS mode to separate new public functions - `findContoursLinkRuns` (it uses completely different algorithm)
* ~added new public `cv::approximateChainTC89`~ - ** decided to hide it**
* enabled chain code output (method = 0, no public enum value for this in C++ yet)
* kept old function as `findContours_old` (exported, but not exposed to user)
* added more tests for findContours (`test_contours_new.cpp`), some tests compare results of old function with new one. Following tests have been added:
  * contours of random rectangle
  * contours of many small (1-2px) blobs
  * contours of random noise
  * backport of old accuracy test
  * separate test for LINK RUNS variant

What is left to be done (can be done now or later):
* improve tests: 
  * some tests have limited verification (e.g. only verify contour sizes)
  * perhaps reference data can be collected and stored
  * maybe more test variants can be added (?)
* add enum value for chain code output and a method of returning starting points (e.g. first 8 elements of returned `vector<uchar>` can represent 2 int point coordinates)
* add documentation for new functions - **✔️ DONE**
* check and improve performance (my experiment showed 0.7x-1.1x some time ago)
* remove old functions completely (?)
* change contour return order (BFS) or allow to select it (?)
* return result tree as-is (?) (new data structures should be exposed, bindings should adapt)
2024-04-09 09:37:49 +03:00
..
doc Merge pull request #25042 from mshabunin:doc-upgrade 2024-03-05 16:19:45 +03:00
include/opencv2 Merge pull request #25146 from mshabunin:cpp-contours 2024-04-09 09:37:49 +03:00
misc Merge pull request #24234 from dkurt:distanceTransform_max_dist 2023-10-03 17:23:32 +03:00
perf Merge pull request #24621 from chacha21:remap_relative 2024-02-28 17:20:33 +03:00
src Merge pull request #25146 from mshabunin:cpp-contours 2024-04-09 09:37:49 +03:00
test Merge pull request #25146 from mshabunin:cpp-contours 2024-04-09 09:37:49 +03:00
CMakeLists.txt Merge pull request #24179 from Kumataro:fix24145 2023-08-23 22:53:11 +03:00