Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

upload GpuMat from memory pointer

I want to upload a camera image to a GpuMat without unnecessary copy operations.

I get the image as a naked char* from the camera API and at the moment convert it to a GpuMat approximately like this:

is_GetImageMem(hCam, (void*)pLast);
tmpI = cvCreateImageHeader(cvSize(iWidth, iHeight), IPL_DEPTH_8U, 1);
tmpI->imageData = pLast;
Mat M = cv::cvarrToMat(tmpI);
GpuMat gM.upload(M);

Is this the "optimal" way to do it without copying data around? The CPU memory gets overwritten by the camera next time around, is this OK after I uploaded it to the GPU?

Thanks!