Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Place data of Mat at a specific memoryarea pointed to by a pointer

I have created a memory object on the shared memory with following OpenCL-Function call:

cl_mem buffer_img_GAUSS_TEST = clCreateBuffer(context, CL_MEM_ALLOC_HOST_PTR, sizeof(uchar) * size_cols * size_rows,NULL,&status);

A call of this function gives me the pointer:

uchar *src_ptr;
src_ptr  = (uchar *)clEnqueueMapBuffer(cmdQueue, buffer_img_GAUSS_TEST, CL_TRUE, CL_MAP_READ, 0, sizeof(uchar) * size_cols* size_rows, 0, NULL, NULL, &status);

Now I want to read an image with following OpenCV function call:

Mat img= imread( "scene.jpg", IMREAD_GRAYSCALE );

Is it possible to "say" that the data of the picture should be placed at the data-area pointed to by src_ptr? The area located by the buffer_img_GAUSS_TEST has exactly the size needed for the data of Template

In other words: I want to replace this part of the code, which copys the data from the Image to the address pointed to by src_pointer.

memcpy ( src_ptr, img.data, sizeof(uchar) * img.cols * img.rows);