Ask Your Question

redheli's profile - activity

2019-12-09 14:04:16 -0500 received badge  Notable Question (source)
2018-09-17 03:53:59 -0500 received badge  Popular Question (source)
2015-12-27 13:33:51 -0500 received badge  Student (source)
2013-08-10 06:15:37 -0500 received badge  Supporter (source)
2013-08-10 05:11:20 -0500 commented answer How convert blob/binary data to Mat

berak, You save my day! imdecode works like a charm. Thank you. The data block is a png format image. The final code likes below: std::vector<char> buffer(blob_data,blob_data+len); Mat img = imdecode(buffer,1);

2013-08-10 03:44:47 -0500 asked a question How convert blob/binary data to Mat


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(, blob_data, blob_data_length );

Thank you.