-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
cuda
: Add bindings to allow GpuMat
and Stream
objects to be initialized from memory initialized in other libraries
#23371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…itialized from raw pointers
f3c8a25
to
7539abe
Compare
Added python bindings to enable
GpuMat
andStream
objects to be initialized from raw pointers + updated test cases.This #16513 exposed the memory created by OpenCV
GpuMat
andStream
s to other python libraries whereas this PR should allow OpenCVGpuMat
andStream
objects 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.