Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
53c0189e
Commit
53c0189e
authored
Feb 04, 2020
by
Peter Würtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow access to CUDA memory and stream pointers for interoperability.
parent
43a907dd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
0 deletions
+29
-0
cuda.hpp
modules/core/include/opencv2/core/cuda.hpp
+6
-0
cuda.inl.hpp
modules/core/include/opencv2/core/cuda.inl.hpp
+6
-0
cuda_stream.cpp
modules/core/src/cuda_stream.cpp
+9
-0
test_cuda.py
modules/python/test/test_cuda.py
+8
-0
No files found.
modules/core/include/opencv2/core/cuda.hpp
View file @
53c0189e
...
...
@@ -305,6 +305,9 @@ public:
//! returns true if GpuMat data is NULL
CV_WRAP
bool
empty
()
const
;
// returns pointer to cuda memory
CV_WRAP
void
*
cudaPtr
()
const
;
//! internal use method: updates the continuity flag
CV_WRAP
void
updateContinuityFlag
();
...
...
@@ -681,6 +684,9 @@ public:
//! returns true if stream object is not default (!= 0)
operator
bool_type
()
const
;
//! return Pointer to CUDA stream
CV_WRAP
void
*
cudaPtr
()
const
;
class
Impl
;
private
:
...
...
modules/core/include/opencv2/core/cuda.inl.hpp
View file @
53c0189e
...
...
@@ -343,6 +343,12 @@ bool GpuMat::empty() const
return
data
==
0
;
}
inline
void
*
GpuMat
::
cudaPtr
()
const
{
return
data
;
}
static
inline
GpuMat
createContinuous
(
int
rows
,
int
cols
,
int
type
)
{
...
...
modules/core/src/cuda_stream.cpp
View file @
53c0189e
...
...
@@ -535,6 +535,15 @@ Stream& cv::cuda::Stream::Null()
#endif
}
void
*
cv
::
cuda
::
Stream
::
cudaPtr
()
const
{
#ifndef HAVE_CUDA
return
nullptr
;
#else
return
impl_
->
stream
;
#endif
}
cv
::
cuda
::
Stream
::
operator
bool_type
()
const
{
#ifndef HAVE_CUDA
...
...
modules/python/test/test_cuda.py
View file @
53c0189e
...
...
@@ -26,5 +26,13 @@ class cuda_test(NewOpenCVTests):
self
.
assertTrue
(
np
.
allclose
(
cuMat
.
download
(),
npMat
))
def
test_cuda_interop
(
self
):
npMat
=
(
np
.
random
.
random
((
128
,
128
,
3
))
*
255
)
.
astype
(
np
.
uint8
)
cuMat
=
cv
.
cuda_GpuMat
()
cuMat
.
upload
(
npMat
)
self
.
assertTrue
(
cuMat
.
cudaPtr
()
!=
0
)
stream
=
cv
.
cuda_Stream
()
self
.
assertTrue
(
stream
.
cudaPtr
()
!=
0
)
if
__name__
==
'__main__'
:
NewOpenCVTests
.
bootstrap
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment