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


i want to be able to work on the same data in the gpu and the cpu
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?



لینک منبع

پاسخ دهید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *