title: Converting a .mat file from MATLAB into cv::Mat matrix in OpenCV
body: <p>I have some MATLAB code that I want to migrate to OpenCV. The data that the MATLAB code uses is stored in a .mat file which is then loaded at run time. </p>
  
  <p>I converted this .mat file into a .csv file and am then reading this data into OpenCV as a string using ifstream. I am having problems converting this string into a data-structure that I can then use in OpenCV.</p>
  
  <p>Is there anyway that I can convert the .mat file / .csv file to a Mat data structure in OpenCV?</p>
  
  <p>Edit: Based on the Answer I received, I was successful in reading MATLAB data into OpenCV using a YML file. This I did in a MAC environment. However, when I try to read the file with the same piece of code in a Windows environment, the file is not being read. Just wondering if anyone ran into such an issue. Below is my code snippet: </p>
  
  <pre><code>// OpenCVDemo.cpp : Defines the entry point for the console application.
  // Created for build/install tutorial, Microsoft Visual Studio and OpenCV 2.4.0
  
  #include "stdafx.h"
  
  #include &lt;cv.h&gt;
  #include &lt;cxcore.h&gt;
  #include &lt;highgui.h&gt;
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  int _tmain(int argc, _TCHAR* argv[])
  {  
          cout &lt;&lt; "Loading the basis." &lt;&lt; endl;
  
          FileStorage fs1("basis.yml", FileStorage::READ);
  
          cv::FileNode B = fs1["B"];
  
          if (B.EMPTY)
          {
              cout &lt;&lt; "File is empty or does not exist" &lt;&lt; endl;
              return 1;
          }
  
          fs1["B"] &gt;&gt; basis;
  
          cout &lt;&lt; basis.cols &lt;&lt; endl;
  
          fs1.release();
  
              return 0;
  }
  </code></pre>