Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can create GpuMat object for existed pointer and GpuMat will not delete this memory in destructor:

void* data;
size_t step;
cudaMalloc2D(&data, &step, width * sizeof(float), height);
GpuMat mat(height, width, CV_32FC1, (uchar*) data, step);
gpu::bitwize_not(mat, mat);

And you can get device pointer from GpuMat with ptr<> method:

float* data = mat.ptr<float>();
size_t step = mat.step;

The same is true for cv::Mat and CPU memory.