OpenCV FileStorage how to read vector of structures?
<p>I write vector with some data like this:</p>

<pre><code>string filename= itemName+".yml";

FileStorage fs(filename, FileStorage::WRITE);
fs &lt;&lt; "number_of_objects" &lt;&lt; (int)vec.size();
fs &lt;&lt; "objects" &lt;&lt; "[";
for( int i=0; i &lt; (int)vec.size(); ++i )
{
    fs &lt;&lt; "{";
    fs &lt;&lt; "x" &lt;&lt; rc.x/imageScale;
    fs &lt;&lt; "y" &lt;&lt; rc.y/imageScale;
    fs &lt;&lt; "w" &lt;&lt; rc.width/imageScale;
    fs &lt;&lt; "h" &lt;&lt; rc.height/imageScale;
    fs &lt;&lt; "}";
}
fs &lt;&lt; "]";
</code></pre>

<p>But I can't read them back.</p>

<pre><code>FileStorage fs(filename, FileStorage::READ);

if(!fs.isOpened())
    return false;

int nObjects= 0;
fs["number_of_objects"] &gt;&gt; nObjects;
imageMarkupData.resize(nObjects);
for( int i=0; i &lt; nObjects; ++i )
{
    int x,y,w,h;
    fs["x"] &gt;&gt; x;
    fs["y"] &gt;&gt; y;
    fs["w"] &gt;&gt; w;
    fs["h"] &gt;&gt; h;

    //...
}
</code></pre>

<p>What is the proper way?</p>