The best way to export opencv data and import in matlab
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?
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++.