Opencv 3.4.6-dev
Python 3.6.8
There is a problem in seamlessClone that was produced by this pr #12512.
- 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.
- 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:

So you can see that circle inside image is gone but circle on a border is left here.
Opencv 3.4.6-dev
Python 3.6.8
There is a problem in seamlessClone that was produced by this pr #12512.
opencv/modules/photo/src/seamless_cloning.cpp
Line 77 in 72ccb5f
this line places zeros on mask borders.
Here is code to reproduce:
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:
So you can see that circle inside image is gone but circle on a border is left here.