Skip to content

seamlessClone bug #15294

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

Closed
Kepnu4 opened this issue Aug 13, 2019 · 6 comments
Closed

seamlessClone bug #15294

Kepnu4 opened this issue Aug 13, 2019 · 6 comments

Comments

@Kepnu4
Copy link

Kepnu4 commented Aug 13, 2019

Opencv 3.4.6-dev
Python 3.6.8

There is a problem in seamlessClone that was produced by this pr #12512.

  1. When mask is on borders only (like border line) it's just crashes. It happens because
    Mat mask_inner = mask(Rect(1, 1, mask.cols - 2, mask.rows - 2));

    this line places zeros on mask borders.
  2. It produces undesirable ghost effect on borders

Here is code to reproduce:

dst = np.ones((101, 101, 3), np.uint8) * 255
src = np.ones((101, 101, 3), np.uint8) * 255
cv.circle(dst,  center=(50, 50), radius=5, color=(0, 0, 255), thickness=-1)
cv.circle(dst, center=(50, 0), radius=5, color=(0, 0, 255), thickness=-1)

mask = np.zeros((101, 101, 1), np.uint8)
mask[:LINES,:] = 255

res = cv.seamlessClone(src, dst, mask, (50, 50), cv.NORMAL_CLONE)
cv.imwrite('result.png', np.concatenate([dst, src, np.concatenate([mask, mask, mask], axis=2), res], axis=1))

That's even stranger behavior
If i set LINES to 1 or 2 i get
terminate called after throwing an instance of 'std::length_error' what(): vector::_M_default_append Aborted (core dumped)
If i set LINES to 3 i get
Traceback (most recent call last): File "seamless_test.py", line 13, in <module> res = cv.seamlessClone(src, dst, mask, (50, 50), cv.NORMAL_CLONE) cv2.error: OpenCV(3.4.6-dev) /home/vfilev/packages/opencv/modules/core/src/matrix_wrap.cpp:1658: error: (-215:Assertion failed) !fixedSize() in function 'release'

and if i set LINES to 60 i get the result below
Example:
result

So you can see that circle inside image is gone but circle on a border is left here.

@sturkmen72
Copy link
Contributor

@Kepnu4 could you provide the code ( reproducer ) . let me check it.

@Kepnu4
Copy link
Author

Kepnu4 commented Aug 14, 2019

@sturkmen72 yes, sure, i updated report.

@sturkmen72
Copy link
Contributor

@Kepnu4 if mask has white pixels only on borders in my opinion it is misusing mask concept and not worth to fix.

@Kepnu4
Copy link
Author

Kepnu4 commented Aug 16, 2019

@sturkmen72 yeah, maybe. But still don't you find that crash with valid arguments is not expected behaviour? And it's worth check inside for such mask

@alalek
Copy link
Member

alalek commented Aug 16, 2019

@Kepnu4 Could you try the fix from the linked PR above: #15316 ?

@alalek
Copy link
Member

alalek commented Oct 27, 2020

@ForeverBeliever Please fill a separate issue with complete minimal reproducer (including input data - you can capture them before the failed call).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants