XML : How to read vector

I was wondering if it was possible to load a vector of vector of Point2f from an xml file, using the cv::FileStorage class.

This is what I tried for saving:

  filestorage  << "RightImPoints" << "{";  for (int i = 0; i < rimPoint.size(); ++i)  {      Mat outMat(rimPoint[i]);      filestorage << "RightImPoints_" + IntToString(i) << outMat;  }  filestorage << "}";    

And this is for loading:

  FileNode k = n["RightImPoints"];  int i = 0;  for (FileNodeIterator it = k.begin(); it!=k.end(); ++it)  {      Mat inMat;      filestorage["RightImPoints_" + IntToString(i)] >> inMat;      vector<Point2f> tmp = Mat_<Point2f>(inMat);      ++i;      rimPoint.push_back(tmp);  }    

Where rimPoint is a vector< vector< Point2f > > and IntToString is defined as follow:

  string IntToString(int number)  {    stringstream ss;    ss << number;    return ss.str();  }    

Can anyone point me in the right direction? Thanks.

No comments:

Post a Comment