Save MAT without header

asked 2014-09-16 23:23:45 -0500

Himanshu gravatar image

updated 2015-09-30 12:19:37 -0500

Hi,

I am using FileStorage to write out Mat object (in my case it's a depthMap from Kinect). FileStorage either saves it as XML or YAML with headers. I tried using 'for loop' to save only the data, but its time consuming. Is there a way where I can save only the data of MAT object directly in a file without the headers?

Thanks.

edit retag flag offensive close merge delete

Comments

if you want to reconstruct a Mat from that, you'll probably need the header information. if you don't, you can write similar to cout << img << endl;

berak gravatar imageberak ( 2014-09-17 00:44:58 -0500 )edit

you can try file operation using fstream header. open a file and write into it as fout<<img;

jamesnzt gravatar imagejamesnzt ( 2014-09-18 04:04:04 -0500 )edit

@berak@jamesnzt - I have tried that cout (fout) operation to write the MAT in the file. But it still saves it in a YAML format with first two lines as header and then a field called data which contains the values. I just want to write the values in a file. It seems OpenCV can only save it as YAML or XML format.

Himanshu gravatar imageHimanshu ( 2014-09-22 02:54:48 -0500 )edit

i don't see your problem:

Mat m = Mat::eye(3,3,0);

cerr << m << endl;

[1, 0, 0;
  0, 1, 0;
  0, 0, 1]
berak gravatar imageberak ( 2014-09-22 03:00:43 -0500 )edit