cuda: Add bindings to allow GpuMat and Stream objects to be initialized from memory initialized in other libraries#23371
Conversation
GpuMat and Stream objects to be initailized from memory initialized in other librariesGpuMat and Stream objects to be initialized from memory initialized in other libraries
076edfb to
25cc357
Compare
|
Oh, this is a wonderful idea! This will make life so much easier when performing cross-library interop. |
|
Thanks a lot for the contribution! Couple of general notes:
|
I've tried adding this macro, for example but it doesn't generate the python bindings, what is the required format for applying it to generate bindings and disable the export of the function to the shared library? |
25cc357 to
4a6a441
Compare
|
Looks like you need |
|
If I combine the two, e.g. then the automatically generated code for the bindings has an extra space and becomes instead of resulting in a compilation error. |
|
@asmorkalov |
GpuMat and Stream objects to be initialized from memory initialized in other librariescuda: Add bindings to allow GpuMat and Stream objects to be initialized from memory initialized in other libraries
c91a5c7 to
f3c8a25
Compare
|
@asmorkalov I'm not sure what is causing the failure as I don't have a mac to test on. I suspect it could be the use of the optional |
|
I'll take a look. |
| cuMatFromPtrSz = cv.cuda.createGpuMatFromCudaMemory(cuMat.size(),cuMat.type(),cuMat.cudaPtr(), cuMat.step) | ||
| self.assertTrue(cuMat.cudaPtr() == cuMatFromPtrSz.cudaPtr()) | ||
| cuMatFromPtrRc = cv.cuda.createGpuMatFromCudaMemory(cuMat.size()[1],cuMat.size()[0],cuMat.type(),cuMat.cudaPtr(), cuMat.step) | ||
| self.assertTrue(cuMat.cudaPtr() == cuMatFromPtrRc.cudaPtr()) |
There was a problem hiding this comment.
@asmorkalov we don't have python tests (and build) on CI with CUDA: https://github.com/opencv/opencv/actions/runs/4753621211/jobs/8445779900?pr=23371 (there is dnn test only)
|
Tested manually with Ubuntu 18.04, Python 3.6, CUDA 10.2. |
…itialized from raw pointers
f3c8a25 to
7539abe
Compare
Added python bindings to enable
GpuMatandStreamobjects to be initialized from raw pointers + updated test cases.This #16513 exposed the memory created by OpenCV
GpuMatandStreams to other python libraries whereas this PR should allow OpenCVGpuMatandStreamobjects to use raw pointers to memory created in other python libraries.Related issues rapidsai/cucim#329 (comment) and opencv/opencv-python#818
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.