Skip to content

Commit

Permalink
Stream default to Stream::Null() when no default in function prototype
Browse files Browse the repository at this point in the history
this corrects bug #16592 where a Stream is created at
each GpuMat::load(arr,stream) call

a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
add test_cuda_upload_download_stream to test_cuda.py
  • Loading branch information
r2d3 committed May 1, 2021
1 parent 1dacea3 commit 6a4bfc0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/python/src2/gen2.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class FormatStrings:
"double": ArgTypeInfo("double", FormatStrings.double, "0", True),
"c_string": ArgTypeInfo("char*", FormatStrings.string, '(char*)""'),
"string": ArgTypeInfo("std::string", FormatStrings.object, None, True),
"Stream": ArgTypeInfo("Stream", FormatStrings.object, 'Stream::Null()', True),
}


Expand Down
9 changes: 9 additions & 0 deletions modules/python/test/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ def test_cuda_upload_download(self):

self.assertTrue(np.allclose(cuMat.download(), npMat))

def test_cuda_upload_download_stream(self):
stream = cv.cuda_Stream()
npMat = (np.random.random((128, 128, 3)) * 255).astype(np.uint8)
cuMat = cv.cuda_GpuMat(128,128, cv.CV_8UC3)
cuMat.upload(npMat, stream)
npMat2 = cuMat.download(stream=stream)
stream.waitForCompletion()
self.assertTrue(np.allclose(npMat2, npMat))

def test_cuda_interop(self):
npMat = (np.random.random((128, 128, 3)) * 255).astype(np.uint8)
cuMat = cv.cuda_GpuMat()
Expand Down

0 comments on commit 6a4bfc0

Please sign in to comment.