Ask Your Question

Mat vs GpuMat (other than being on the gpu)

asked 2014-07-08 15:09:39 -0500

abelis gravatar image

Quick (and dumb) question is there a difference between a Mat and GpuMat? If I were to create a Mat on the CPU, copy it to the GPU using the Cuda copy calls then perform actions on that Mat in a Cuda kernel, vs creating a GPUMat, passing that pointer to my Cuda kernel and performing actions on that, is there anything different between the two?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-07-08 15:20:31 -0500

unxnut gravatar image

Before you do this you may want to check if the host memory can be mapped into GPU memory by using the function gpu::CudaMem::canMapHostMemory. If the mapping is supported, you should be good to go.

edit flag offensive delete link more


Does it matter that I am trying to do a "cuMemcpyHtoD" instead of trying to map and use the host memory? I am using the pre-built version of openCV (with no GPU support) and instead of recompiling to get the GPU support from OpenCV, I was just going to do a "quick and dirty" attempt at using the source code to one of the Optical Flow Algorithm in the .cu file and changing some variable types etc. but I did not know if the GPUMat was extremely different from the cvMat or basically interchangeable. Its a long story of why I am doing this but it boiled down to performance of opencv and UDP streams (h.264).

abelis gravatar imageabelis ( 2014-07-08 16:09:16 -0500 )edit

I'll suggest not mixing OpenCV GPU and CUDA calls. The results may be unpredictable.

unxnut gravatar imageunxnut ( 2014-07-08 17:58:02 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-07-08 15:09:39 -0500

Seen: 1,076 times

Last updated: Jul 08 '14