Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How convert blob/binary data to Mat

Hi,

I get a block of data from socket, which is a image. I can save this data to a file, like image.png. it shows picture instant in the folder.

the problem is : how can I convert this blob or brinary data to Mat format? I tried below code. but not work. as I don't know the col and row of the image.(each time the image size if different)

Mat image;
image.create( rows, cols, CV_16UC1 );
memcpy( image.data, blob_data, blob_data_length );

Thank you.

How convert blob/binary data to Mat

Hi,

I get a block of data from socket, which is a image. I can save this data to a file, like image.png. it shows picture instant in the folder.

the problem is : how can I convert this blob or brinary data to Mat format? I tried below code. but not work. as I don't know the col and row of the image.(each time the image size if different)

Mat image;
image.create( rows, cols, CV_16UC1 );
memcpy( image.data, blob_data, blob_data_length );

Thank you.