Fix #21894: Wrap constructor to Python to create initialized cuda::BufferPool object.

pull/21919/head
Alexander Smorkalov 3 years ago
parent 2bf4135afc
commit 2402fa4824
  1. 2
      modules/core/include/opencv2/core/cuda.hpp
  2. 10
      modules/python/test/test_cuda.py

@ -689,7 +689,7 @@ class CV_EXPORTS_W BufferPool
public:
//! Gets the BufferPool for the given stream.
explicit BufferPool(Stream& stream);
CV_WRAP explicit BufferPool(Stream& stream);
//! Allocates a new GpuMat of given size and type.
CV_WRAP GpuMat getBuffer(int rows, int cols, int type);

@ -45,5 +45,15 @@ class cuda_test(NewOpenCVTests):
asyncstream = cv.cuda_Stream(1) # cudaStreamNonBlocking
self.assertTrue(asyncstream.cudaPtr() != 0)
def test_cuda_buffer_pool(self):
cv.cuda.setBufferPoolUsage(True)
cv.cuda.setBufferPoolConfig(cv.cuda.getDevice(), 1024 * 1024 * 64, 2)
stream_a = cv.cuda.Stream()
pool_a = cv.cuda.BufferPool(stream_a)
cuMat = pool_a.getBuffer(1024, 1024, cv.CV_8UC3)
cv.cuda.setBufferPoolUsage(False)
self.assertEqual(cuMat.size(), (1024, 1024))
self.assertEqual(cuMat.type(), cv.CV_8UC3)
if __name__ == '__main__':
NewOpenCVTests.bootstrap()

Loading…
Cancel
Save