Merge pull request #18505 from alalek:fix_python_test

This commit is contained in:
Alexander Alekhin 2020-10-05 17:01:46 +00:00
commit aabeb8a18e

View File

@ -24,10 +24,12 @@ class copytomask_test(NewOpenCVTests):
valeurBGRSup = np.array([70, 70,255]) valeurBGRSup = np.array([70, 70,255])
maskRed = cv.inRange(img, valeurBGRinf, valeurBGRSup) maskRed = cv.inRange(img, valeurBGRinf, valeurBGRSup)
#New binding #New binding
dstcv = np.full(np.array((2, 2, 1))*img.shape, 255, dtype=img.dtype) dstcv = np.ndarray(np.array((2, 2, 1))*img.shape, dtype=img.dtype)
dstcv.fill(255)
cv.copyTo(img, maskRed, dstcv[:img.shape[0],:img.shape[1],:]) cv.copyTo(img, maskRed, dstcv[:img.shape[0],:img.shape[1],:])
#using numpy #using numpy
dstnp = np.full(np.array((2, 2, 1))*img.shape, 255, dtype=img.dtype) dstnp = np.ndarray(np.array((2, 2, 1))*img.shape, dtype=img.dtype)
dstnp.fill(255)
mask2=maskRed.astype(bool) mask2=maskRed.astype(bool)
_, mask_b = np.broadcast_arrays(img, mask2[..., None]) _, mask_b = np.broadcast_arrays(img, mask2[..., None])
np.copyto(dstnp[:img.shape[0],:img.shape[1],:], img, where=mask_b) np.copyto(dstnp[:img.shape[0],:img.shape[1],:], img, where=mask_b)