# Revision history [back]

### 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.

 2 retagged sturkmen 6076 ●3 ●42 ●71 https://github.com/stu...

### 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.