Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to give ownership of Mat data to other structure

I'm using OpenCV and SDL in tandem, I've declared a Mat in a function and once I'm done with it I give it's data to create an SDL_Surface, I'm assuming that once we leave the function scope the mat is recycled? I'm getting an access violation as soon as I use the sdl_surface and the data it contains is garbage.

I can also say that the function SDL_CreateRGBSurfaceFrom doesn't copy the data is uses what's stored at the pointer.

Here's the function, I haven't written C++ in a while so perhaps I'm making a big mistake: http://pastie.org/4333990

How to give ownership of Mat data to other structure

I'm using OpenCV and SDL in tandem, I've declared a Mat in a function and once I'm done with it I give it's data to create an SDL_Surface, I'm assuming that once we leave the function scope the mat is recycled? I'm getting an access violation as soon as I use the sdl_surface and the data it contains is garbage.

I can also say that the function SDL_CreateRGBSurfaceFrom doesn't copy the data is it uses what's stored at the pointer. pointer location.

Here's the function, I haven't written C++ in a while so perhaps I'm making a big mistake: http://pastie.org/4333990

click to hide/show revision 3
retagged

How to give ownership of Mat data to other structure

I'm using OpenCV and SDL in tandem, I've declared a Mat in a function and once I'm done with it I give it's data to create an SDL_Surface, I'm assuming that once we leave the function scope the mat is recycled? I'm getting an access violation as soon as I use the sdl_surface and the data it contains is garbage.

I can also say that the function SDL_CreateRGBSurfaceFrom doesn't copy the data it uses what's stored at the pointer location.

Here's the function, I haven't written C++ in a while so perhaps I'm making a big mistake: http://pastie.org/4333990