Home OpenCV & CUDA sharing same data for cv::gpu::GpuMat and cv::Mat
Reply: 0

OpenCV & CUDA sharing same data for cv::gpu::GpuMat and cv::Mat

Ariel Nahum
1#
Ariel Nahum Published in 2017-12-07 12:07:29Z


i want to be able to work on the same data in the gpu and the cpu on Nvidia Tx1, so that i will be responsible for the sync.
the normal option is to use separate memory and upload & download methods for example:

GpuMat gpumat;
//.. make some processing on the image on the gpu //
... ...........
Mat cpuMat;
gpumat.download(cpuMat)
//now memory is copied into the cpu.

the problem with the above is that download is a heavy call.

question is, can i just make the GpuMat and Mat point to the same void* data?
by creating them both with a CudaMallocManaged()?
do Mat and GpuMat access and arrange their data in exactly the same way?
:
void* data;
CudaMallocManaged(&data, 500*500);
GpuMat gpumat(500,500, CV_8UC3, data, AUTO_STEP);
Mat mat(500,500, CV_8UC3, data , AUTO_STEP);

and work on both in that way?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.297881 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO