From 82ae9ef54181b64e1f7400001fda3ae72e4c720a Mon Sep 17 00:00:00 2001 From: huangziqing <270704881@qq.com> Date: Mon, 2 May 2022 00:54:17 +0800 Subject: [PATCH] Wrap gpuMat::release to Python --- modules/core/include/opencv2/core/cuda.hpp | 2 +- modules/python/test/test_cuda.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index 09220cd6b2..1ebea07c0d 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -155,7 +155,7 @@ public: CV_WRAP void create(Size size, int type); //! decreases reference counter, deallocate the data when reference counter reaches 0 - void release(); + CV_WRAP void release(); //! swaps with other smart pointer CV_WRAP void swap(GpuMat& mat); diff --git a/modules/python/test/test_cuda.py b/modules/python/test/test_cuda.py index a047a8b2f4..a5f3fae847 100644 --- a/modules/python/test/test_cuda.py +++ b/modules/python/test/test_cuda.py @@ -55,5 +55,14 @@ class cuda_test(NewOpenCVTests): self.assertEqual(cuMat.size(), (1024, 1024)) self.assertEqual(cuMat.type(), cv.CV_8UC3) + def test_cuda_release(self): + npMat = (np.random.random((128, 128, 3)) * 255).astype(np.uint8) + cuMat = cv.cuda_GpuMat() + cuMat.upload(npMat) + cuMat.release() + self.assertTrue(cuMat.cudaPtr() == 0) + self.assertTrue(cuMat.step == 0) + self.assertTrue(cuMat.size() == (0, 0)) + if __name__ == '__main__': NewOpenCVTests.bootstrap()