title: OpenCV filestorage error
body: <p>Hello I would like to export 3 histograms (rgb) to a .xml file then read from .xml and save to another matrix. </p>
  
  <p>Code: </p>
  
  <pre><code>int main(int argc, char** argv)
  {
      Mat org,cmp, dst;
  
      /// Load image
      org = imread("arrowr.png");
      cmp = imread("cat.jpg");
  
      if (!org.data)
      {
          return -1;
      }
      /// Separate the image in 3 places ( B, G and R )
      Mat bgr_planes_org[3] = {};         //zmena z vector&lt;Mat&gt; bgr_planes;
      split(org, bgr_planes_org);
  
      /// Establish the number of bins
      int histSize = 256;
  
      /// Set the ranges ( for B,G,R) )
      float range[] = { 0, 256 };
      const float* histRange = { range };
  
      bool uniform = true; bool accumulate = false;
  
      Mat b_hist_org, g_hist_org, r_hist_org;
  
  
      /// Compute the histograms:
      calcHist(&amp;bgr_planes_org[0], 1, 0, Mat(), b_hist_org, 1, &amp;histSize, &amp;histRange, uniform, accumulate);
      calcHist(&amp;bgr_planes_org[1], 1, 0, Mat(), g_hist_org, 1, &amp;histSize, &amp;histRange, uniform, accumulate);
      calcHist(&amp;bgr_planes_org[2], 1, 0, Mat(), r_hist_org, 1, &amp;histSize, &amp;histRange, uniform, accumulate);
  
      // Draw the histograms for B, G and R
      int hist_w = 512; int hist_h = 400;
      int bin_w = cvRound((double)hist_w / histSize);
  
      Mat histImage(hist_h, hist_w, CV_8UC3, Scalar(0, 0, 0));
  
      /// Normalize the result to [ 0, histImage.rows ]
      normalize(b_hist_org, b_hist_org, 0, histImage.rows, NORM_MINMAX, -1, Mat());
      normalize(g_hist_org, g_hist_org, 0, histImage.rows, NORM_MINMAX, -1, Mat());
      normalize(r_hist_org, r_hist_org, 0, histImage.rows, NORM_MINMAX, -1, Mat());
  
      Mat mat_r, mat_g, mat_b;
      string filename = "test.xml";
      FileStorage fs(filename, FileStorage::WRITE);
      fs &lt;&lt; "blu" &lt;&lt; b_hist_org;
      fs &lt;&lt; "grn" &lt;&lt; g_hist_org;
      fs &lt;&lt; "red" &lt;&lt; r_hist_org;
      fs.release();
  
      FileStorage fs(filename, FileStorage::READ);
      fs["blu"] &gt;&gt; mat_b;
      fs["red"] &gt;&gt; mat_r;
      fs["grn"] &gt;&gt; mat_g;
      fs.release();
  
          cout &lt;&lt; mat_r &lt;&lt; endl;
          cout &lt;&lt; mat_g &lt;&lt; endl;
          cout &lt;&lt; mat_b &lt;&lt; endl;
  
          system("pause");
  
      return 0;
  }
  </code></pre>
  
  <p>When I try to run it it throws me this "Unhandled exception at 0x00007FF96ECA8A5C in ConsoleApplication2.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000A4D911BF40."</p>
  
  <p>I think its something with <code>FileStorage::READ</code>. When i comment the section where i read from .xml it works without error. It also works when i put only one matrix in and then read it .</p>
  
  <p>I also noticed that in the .xml file i have the exported data like this:</p>
  
  <pre><code>&lt;blu type_id="opencv-matrix"&gt;
  &lt;rows&gt;256&lt;/rows&gt;
  &lt;cols&gt;1&lt;/cols&gt;
  &lt;dt&gt;f&lt;/dt&gt;
  &lt;data&gt;
  "blue matrix data"
  &lt;/data&gt;&lt;/blu&gt;
  &lt;blu&gt;grn&lt;/blu&gt;
  &lt;blu type_id="opencv-matrix"&gt;
  &lt;rows&gt;256&lt;/rows&gt;
  &lt;cols&gt;1&lt;/cols&gt;
  &lt;dt&gt;f&lt;/dt&gt;
  &lt;data&gt;
  "green matrix data"    
  &lt;/data&gt;&lt;/blu&gt;
  &lt;red type_id="opencv-matrix"&gt;
  &lt;rows&gt;256&lt;/rows&gt;
  &lt;cols&gt;1&lt;/cols&gt;
  &lt;dt&gt;f&lt;/dt&gt;
  &lt;data&gt;
  "red matrix data"
  &lt;/data&gt;&lt;/red&gt;
  &lt;/opencv_storage&gt;
  </code></pre>
  
  <p>Why is there this <code>&lt;blu&gt;grn&lt;/blu&gt;</code>? I want my green matrix with the header <code>&lt;grn&gt;</code>. Why is the <code>grn</code> under the <code>&lt;blu&gt;</code> header?</p>
  
  <p>According to openCV i should have three headers for each matrix. <a href="http://docs.opencv.org/2.4/doc/tutorials/core/file_input_output_with_xml_yml/file_input_output_with_xml_yml.html" rel="nofollow">http://docs.opencv.org/2.4/doc/tutorials/core/file_input_output_with_xml_yml/file_input_output_with_xml_yml.html</a></p>
  
  <p>Any help/link to solution would be cool.</p>