Is that possible to use a string as a name in opencv FileStorage

asked 2014-06-24 04:02:50 -0500

TripleS gravatar image

I'd like to write an xml file using opencv FileStorage object.

Most of the examples I get to see works like the following

    FileStorage fs("d:\\1.xml" , FileStorage::WRITE); 
    fs << "one" << 1;

I'd like to write a section with modified name variable , which means that the text would not have to be inserted in compile time. I look for something like this:

    string st = "1"; 
    fs << st.c_str() << 1;

However I keep on getting run time error. it's refused to work, I have tried using opencv string type, stl string type , char* , but still can't make it work.

Any help would be very appreciated

edit retag flag offensive close merge delete