From 8baf46c0a80cec2790ec05fc560bfcbda06df3e0 Mon Sep 17 00:00:00 2001 From: cudawarped <12133430+cudawarped@users.noreply.github.com> Date: Fri, 23 Sep 2022 19:10:59 +0300 Subject: [PATCH] Add bindings and test --- modules/photo/include/opencv2/photo/cuda.hpp | 43 ++++++++++++++++++++++------ modules/python/test/test_cuda.py | 5 ++++ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/modules/photo/include/opencv2/photo/cuda.hpp b/modules/photo/include/opencv2/photo/cuda.hpp index a2f3816..b6ab40a 100644 --- a/modules/photo/include/opencv2/photo/cuda.hpp +++ b/modules/photo/include/opencv2/photo/cuda.hpp @@ -65,11 +65,20 @@ BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supporte fastNlMeansDenoising */ CV_EXPORTS void nonLocalMeans(InputArray src, OutputArray dst, - float h, - int search_window = 21, - int block_size = 7, - int borderMode = BORDER_DEFAULT, - Stream& stream = Stream::Null()); + float h, + int search_window = 21, + int block_size = 7, + int borderMode = BORDER_DEFAULT, + Stream& stream = Stream::Null()); +CV_WRAP inline void nonLocalMeans(const GpuMat& src, CV_OUT GpuMat& dst, + float h, + int search_window = 21, + int block_size = 7, + int borderMode = BORDER_DEFAULT, + Stream& stream = Stream::Null()) +{ + nonLocalMeans(InputArray(src), OutputArray(dst), h, search_window, block_size, borderMode, stream); +}; /** @brief Perform image denoising using Non-local Means Denoising algorithm with several computational @@ -93,10 +102,18 @@ FastNonLocalMeansDenoising::labMethod. fastNlMeansDenoising */ CV_EXPORTS void fastNlMeansDenoising(InputArray src, OutputArray dst, - float h, - int search_window = 21, - int block_size = 7, - Stream& stream = Stream::Null()); + float h, + int search_window = 21, + int block_size = 7, + Stream& stream = Stream::Null()); +CV_WRAP inline void fastNlMeansDenoising(const GpuMat& src, CV_OUT GpuMat& dst, + float h, + int search_window = 21, + int block_size = 7, + Stream& stream = Stream::Null()) +{ + fastNlMeansDenoising(InputArray(src), OutputArray(dst), h, search_window, block_size, stream); +} /** @brief Modification of fastNlMeansDenoising function for colored images @@ -124,6 +141,14 @@ CV_EXPORTS void fastNlMeansDenoisingColored(InputArray src, OutputArray dst, int search_window = 21, int block_size = 7, Stream& stream = Stream::Null()); +CV_WRAP inline void fastNlMeansDenoisingColored(const GpuMat& src, CV_OUT GpuMat& dst, + float h_luminance, float photo_render, + int search_window = 21, + int block_size = 7, + Stream& stream = Stream::Null()) +{ + fastNlMeansDenoisingColored(InputArray(src), OutputArray(dst), h_luminance, photo_render, search_window, block_size, stream); +} //! @} photo diff --git a/modules/python/test/test_cuda.py b/modules/python/test/test_cuda.py index a5f3fae..586c0ec 100644 --- a/modules/python/test/test_cuda.py +++ b/modules/python/test/test_cuda.py @@ -64,5 +64,10 @@ class cuda_test(NewOpenCVTests): self.assertTrue(cuMat.step == 0) self.assertTrue(cuMat.size() == (0, 0)) + def test_cuda_denoising(self): + self.assertEqual(True, hasattr(cv.cuda, 'fastNlMeansDenoising')) + self.assertEqual(True, hasattr(cv.cuda, 'fastNlMeansDenoisingColored')) + self.assertEqual(True, hasattr(cv.cuda, 'nonLocalMeans')) + if __name__ == '__main__': NewOpenCVTests.bootstrap() -- 2.7.4