FileStorage: can write but can't read Size, Rect, etc.
I am writing Size
to a yaml file using FileStorage
:
FileStorage fs("info.yml", FileStorage::WRITE);
fs << "gridSize" << Size(31,31);
The file content is after writing:
%YAML:1.0
gridSize: [ 31, 31 ]
I cannot read the Size object again by doing:
Size gridSize;
FileStorage fs("info.yml", FileStorage::READ);
fs["gridSize"] >> gridSize;
Is this a bug? Lack of feature? Or is this completely planned behavior? What is the best way to read OpenCV data structures?
A workaround would be to save integers:
gridSizeWidth
andgridSizeHeight
, although that may look uglyDid you find an acceptable solution for this problem? I'm experiencing the same thing and it will be annoying to have to alter my xml file.