Skip to content

Conversation

@inayd
Copy link
Contributor

@inayd inayd commented Sep 24, 2024

Fixes the bug described in #26130

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • 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

@asmorkalov
Copy link
Contributor

@mshabunin could you take a look?

int imgSize = 50;
int type = CV_8UC1;
int shift = 0;
cv::LineTypes lineType = LINE_8;
Copy link
Contributor

Choose a reason for hiding this comment

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

What about other line types? LINE_AA? Will it work the same as before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LINE_AA is not affected by the changes of this PR so it works the same, but it does not pass the test due to the reasons mentioned in the other comment.
LINE_4 passes this test with any shift.
LINE_8 passes this test only with a zero shift. It fails for non-zero shifts, most likely because the methods to draw the contour in fillPoly and polylines differ for LINE_8 with non-zero shifts.

if (t0.y != t1.y)
{
pt0c.y = t0.y; pt1c.y = t1.y;
pt0c.x = (int64)(t0.x) << XY_SHIFT;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does any test check clipping scenario? Non-zero shift?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not add tests for all scenarios since fillPoly and polylines handle incoming points slightly different and also have differences in drawing the contours for certain parameters. To make the contours match in all scenarios probably both functions would need further adjustments.

This PR should fix the matching contours for line_type < LINE_AA and zero shift since it used to match before the changes of #23076

@asmorkalov asmorkalov added this to the 4.11.0 milestone Oct 2, 2024
@asmorkalov asmorkalov merged commit 28efc21 into opencv:4.x Oct 7, 2024
28 of 30 checks passed
@asmorkalov asmorkalov mentioned this pull request Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants