Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you map the pointer into a Mat, and the Mat is the exact size and type of what you are copying, you can simply use the copyTo function.

Mat src_mat(img.rows, img.cols, img.type(), src_ptr, *pitch if necessary*);
img.copyTo(src_mat);

copyTo is the only reliable way to do this. Some functions will store their result into it, but not all, and some depend on the other input parameters for where they store it.