Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sorry to say, but what you do in your MatToBytes(cv::Mat image) will defenitely end in a memory leak (you are allocating memory on the stack - the local variable v_char - and will get lost after you end your function). Why not just use memcpy (make sure your data is continuos (isContinuous())?!

cv::Mat img = cv::Mat(image_rows,image_cols,CV_16UC1,image_byte) looks fine to me, however note that a typical image has type CV_8UC1 not CV_16UC1 (and for color CV_8UC3), but I guess that was intentionally.