python: replace numpy.full() to support numpy<1.13
This commit is contained in:
parent
199687a1c5
commit
d7d51e4cc7
@ -24,10 +24,12 @@ class copytomask_test(NewOpenCVTests):
|
||||
valeurBGRSup = np.array([70, 70,255])
|
||||
maskRed = cv.inRange(img, valeurBGRinf, valeurBGRSup)
|
||||
#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],:])
|
||||
#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)
|
||||
_, mask_b = np.broadcast_arrays(img, mask2[..., None])
|
||||
np.copyto(dstnp[:img.shape[0],:img.shape[1],:], img, where=mask_b)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user