From 2db7f8e82764cc4cd26d529155a70499833a0fdf Mon Sep 17 00:00:00 2001 From: chacha21 Date: Thu, 1 Aug 2024 09:36:08 +0200 Subject: [PATCH] Adding getStdAllocator() to cv::cuda::GpuMat To be on par with `cv::Mat`, let's add `cv::cuda::GpuMat::getStdAllocator()` This is useful anyway, because when a user wants to use custom allocators, he might want to resort to the standard default allocator behaviour, not some other allocator that could have been set by `setDefaultAllocator()` --- modules/core/include/opencv2/core/cuda.hpp | 1 + modules/core/src/cuda/gpu_mat.cu | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index 9d210ed7b5..6cd6711582 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -118,6 +118,7 @@ public: //! default allocator CV_WRAP static GpuMat::Allocator* defaultAllocator(); CV_WRAP static void setDefaultAllocator(GpuMat::Allocator* allocator); + CV_WRAP static GpuMat::Allocator* getStdAllocator(); //! default constructor CV_WRAP explicit GpuMat(GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); diff --git a/modules/core/src/cuda/gpu_mat.cu b/modules/core/src/cuda/gpu_mat.cu index c286f28eb0..a86888cac3 100644 --- a/modules/core/src/cuda/gpu_mat.cu +++ b/modules/core/src/cuda/gpu_mat.cu @@ -135,6 +135,7 @@ namespace DefaultAllocator cudaDefaultAllocator; GpuMat::Allocator* g_defaultAllocator = &cudaDefaultAllocator; + GpuMat::Allocator* g_stdAllocator = &cudaDefaultAllocator; } GpuMat::Allocator* cv::cuda::GpuMat::defaultAllocator() @@ -148,6 +149,12 @@ void cv::cuda::GpuMat::setDefaultAllocator(Allocator* allocator) g_defaultAllocator = allocator; } +GpuMat::Allocator* cv::cuda::GpuMat::getStdAllocator() +{ + return g_stdAllocator; +} + + ///////////////////////////////////////////////////// /// create