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);
if your question was: "can i load an image directly into gpu memory ?" - then the answer is NO.
I have a shared memory between the Host(ARM) and the Device (FPGA). on this shared memory i created the buffer. After that i want to read an image and safe the data of the image on the allocated memory which was allocated by clCreateBuffer
Isn't that a problem similar to this one? http://answers.opencv.org/question/45...
not really.
you can build a (shallow) Mat structure around a pointer, but you cannot force imread() to use your memory.
it's another story, if you use your own tga or pgm loader.
It´s the opposite direction. On the thread he initialized a CV:Mat with values located in the shared memory (where the pointer pointed to) but i want to read in a picture in a CV:Mat and save the values on a memory area a pointer is pointing to.
Ok, thanks for pointing that out.