Reputation: 33864
We are compiling using -default-stream=per-thread
to get a per thread stream for CUDA. But when we do: cv::cuda::Stream::Null()
we get a stream pointer that points to the "legacy default stream" (see details here).
How can we get a cv::cuda::Stream
that points to the cuda stream handle CU_STREAM_PER_THREAD
?
More generally, how can we get a cv::cuda::Stream
that points to an existing cudaStream_t
handle?
Upvotes: 1
Views: 843
Reputation: 33864
There is a friend of the cv::cuda::Stream
here called the cv::cuda::StreamAccessor
. This struct has a static member function:
static Stream wrapStream (cudaStream_t stream)
which can be used as follows:
#include <opencv2/core/cuda_stream_accessor.hpp>
#include <cuda.h>
...
auto cvThreadDefaultStream =
cv::cuda::StreamAccessor::wrapStream(CU_STREAM_PER_THREAD);
to get a cv
Stream
that represents the default thread stream.
Upvotes: 3