In the example code, you will notice that sometimes all of the data in a mapping or sequence is stored on a
single line and other times it is stored with one element per line. This is not an automatic formatting
behavior. Instead, it is created by a variant of the mapping and sequence creation strings: “{:” and “:}”
mappings, and “[:” and “:]” for sequences. This feature is only meaningful for YML output; if the output
file is XML, this nuance is ignored and the mapping or sequence is stored as it would have been without the
variant.
Reading from a cv::FileStorage
FileStorage::FileStorage( string fileName, int flag );
The cv::FileStorage can be opened for reading the same way it is opened for writing, except that the
flag argument should be set to cv::FileStorage::READ. As with writing, you can also create an
unopened file storage object with the default constructor and open it later with
cv::FileStorage::open().
FileStorage::open( string fileName, int flag );
Once the file has been opened, the data can be read with either the overloaded array operator
cv::FileStorage::operator[]() or with the iterator cv::FileNodeIterator. Once you
are completely done reading, you then close the file with the cv::FileStorage::release()
member function.
To read from a mapping, the cv::FileStorage::operator[]()