The best way to export opencv data and import in matlab

asked 2015-06-25 10:57:13 -0600

p3p1 gravatar image

updated 2015-06-25 11:10:20 -0600

So I've a question as from title. But I want underline that I will want avoid the mex-file but only use the binary file or xml file. My question in particular is related to export the points tracked with calcOpticalFlowPyrLK and relative error. Up to now, I used the following code but I don't know if it's correct way

outfile.open("file.bin", ios::out | ios::binary);
outfile << status.size() << endl; 
for( int i=0; i < status.size(); i++ )
{       
    if( !status[i] )
        outfile<< 0 << endl;
    else
        outfile << 1 <<endl;

}
outfile << points1 << endl;
outfile << points2<< endl;

stringstream ss (stringstream::in | stringstream::out); 
for(int i=0; i < err.size(); ++i)
{
   ss << err[i] << endl;
}
outfile << ss.str(); 
outfile.close();

where points1 and point2 are the features points tracked by LK algorithm in first frame and second frame respectively. Can you help me?

edit retag flag offensive close merge delete

Comments

Matlab can reads text files in many different formats. Select in matlab your preferred text file format for the import than write it out with C++.

pklab gravatar imagepklab ( 2015-06-26 11:50:37 -0600 )edit