title: Use path as key in FileStorage
body: <p>I am trying to write a file (json/yaml/xml, the format does not matter) that stores a filepath with a specific <code>cv::Mat</code>. As I ended up realizing <a href="https://github.com/opencv/opencv/blob/master/modules/core/src/persistence.cpp#L6907%22here%22" rel="nofollow noreferrer">here</a>, the key combination does not allow for a path (/home/user, for example).</p>
  
  <pre><code>void
  persist_histograms(const QString&amp; filepath, const QHash&lt;QString, Mat&gt;&amp; histograms)
  {
      cv::FileStorage storage(filepath.toStdString(), cv::FileStorage::WRITE);
  
      QHashIterator&lt;QString, Mat&gt; it(histograms);
  
      while (it.hasNext()) {
          it.next();
          storage &lt;&lt; it.key().toStdString() &lt;&lt; it.value();
      }
  }
  </code></pre>
  
  <p>Is this a real limitation of the <code>cv::FileStorage</code>class? Or is there a way of going around it?</p>
  
  <p>The end result should be something like:</p>
  
  <pre><code>{
      "/my/path/to/file.png": "&lt;my cv::Mat serialization here&gt;",
      "/my/path/to/another/file.png": "&lt;my cv::Mat serialization here&gt;",
      ...
  }
  </code></pre>
  
  <h3>Observation</h3>
  
  <p>The error occurs independently of the format. If I pass a <code>filepath</code> that 
  ends with either yaml/json/xml the errors are the same:
  This is the error if a try adding a letter at the beginning of the key:</p>
  
  <p>This is the error I get when trying the code above:</p>
  
  <pre><code>OpenCV Error: Unspecified error (Incorrect element name /home/user/dtd/images/freckled/freckled_0055.jpg) in operator&lt;&lt;, file /build/opencv/src/opencv-3.2.0/modules/core/src/persistence.cpp, line 6877
  terminate called after throwing an instance of 'cv::Exception'
  what():  /build/opencv/src/opencv 3.2.0/modules/core/src/persistence.cpp:6877: error: (-2) Incorrect element name /home/user/dtd/images/freckled/freckled_0055.jpg in function operator&lt;&lt;
  </code></pre>
  
  <p>This is the error I get if I try to add a letter to the beginning of the key.</p>
  
  <pre><code>OpenCV Error: Bad argument (Key names may only contain alphanumeric characters [a-zA-Z0-9], '-', '_' and ' ') in icvJSONWrite, file /build/opencv/src/opencv-3.2.0/modules/core/src/persistence.cpp, line 3896
  </code></pre>