Commit 62775660 authored by Pavel Rojtberg's avatar Pavel Rojtberg

core: python - test cv::copyTo with pre-allocated dst

parent 54a1bbe1
......@@ -24,12 +24,13 @@ class copytomask_test(NewOpenCVTests):
valeurBGRSup = np.array([70, 70,255])
maskRed = cv.inRange(img, valeurBGRinf, valeurBGRSup)
#New binding
dstcv = cv.copyTo(img,maskRed)
dstcv = np.full(np.array((2, 2, 1))*img.shape, 255, dtype=img.dtype)
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)
mask2=maskRed.astype(bool)
_, mask_b = np.broadcast_arrays(img, mask2[..., None])
dstnp = np.ma.masked_array(img, np.logical_not(mask_b))
dstnp =np.ma.filled(dstnp,[0])
np.copyto(dstnp[:img.shape[0],:img.shape[1],:], img, where=mask_b)
self.assertEqual(cv.norm(dstnp ,dstcv), eps)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment