core: python - test cv::copyTo with pre-allocated dst
authorPavel Rojtberg <pavel.rojtberg@igd.fraunhofer.de>
Thu, 28 Mar 2019 11:08:36 +0000 (12:08 +0100)
committerPavel Rojtberg <pavel.rojtberg@igd.fraunhofer.de>
Fri, 29 Mar 2019 12:56:26 +0000 (13:56 +0100)
modules/python/test/test_copytomask.py

index 71ec548..6c78ac8 100644 (file)
@@ -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)