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

imgproc: C-API cleanup, drawContours refactor #25564

Merged
merged 6 commits into from May 17, 2024

Conversation

mshabunin
Copy link
Contributor

Changes:

  • moved several macros from types_c.h to cvdef.h (assuming we will continue using them)
  • removed some cases of C-API usage in imgproc module (CV_TERMCRIT_* and CV_CMP_*)
  • refactored drawContours to use C++ API instead of calling cvDrawContours + test for filled contours with holes (case with non-filled contours is simpler and is covered in some other tests)

Note:

There is one case where old drawContours behavior doesn't match the new one - when contourIdx == -1 (means "draw all contours") and maxLevel == 0 (means draw only selected contours, but not what is inside).

From the docs:

contourIdx Parameter indicating a contour to draw. If it is negative, all the contours are drawn.

maxLevel Maximal level for drawn contours. If it is 0, only the specified contour is drawn. If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This parameter is only taken into account when there is hierarchy available.

Old behavior - only one first contour is drawn:
actual_screenshot_08 05 2024

New behavior (also expected by the test) - all contours are drawn:
expected_screenshot_08 05 2024

@asmorkalov asmorkalov self-requested a review May 8, 2024 12:23
@asmorkalov asmorkalov self-assigned this May 8, 2024
@asmorkalov asmorkalov added this to the 4.10.0 milestone May 8, 2024
@asmorkalov asmorkalov added category: imgproc cleanup Code cleanup (e.g, drop legacy C-API, legacy unmaintained code) labels May 8, 2024
@asmorkalov asmorkalov requested a review from vpisarev May 13, 2024 12:32
Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍

@mshabunin
Copy link
Contributor Author

For some reason ABI verification has failed on buildbot, it complains two function has been removed: https://pullrequest.opencv.org/buildbot/builders/precommit_linux64/builds/107321/steps/Compare%20ABI%20dumps/logs/report-html

The problem is related to the changes in this PR, but I'm not sure if this is a severe issue.

@opencv-alalek
Copy link
Contributor

ABI check has been updated.

@asmorkalov asmorkalov merged commit 6350bfb into opencv:4.x May 17, 2024
28 checks passed
@mshabunin mshabunin deleted the cleanup-imgproc-2 branch May 17, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: imgproc cleanup Code cleanup (e.g, drop legacy C-API, legacy unmaintained code)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants