title: OpenCV 3.0 - How can I create a cv::Mat from CSV string?
body: <p>I'm trying to create a cv::Mat from a CSV string that I pipe from a python-script. I'm currently using python 2.7, C++ and OpenCV 3.0, and all I can find is how to do it in OpenCV 2.4, but the problem is that it differs a lot from 3.0 where the ml::TrainData somehow is used instead. I don't understand how it works, and theres no example code! :-(</p>
  
  <p>What my python-script does is that it pipes the np.array as CSV, it looks like this:</p>
  
  <pre><code>import sys
  import numpy as np
  import csv
  
  
  csvToSend = csv.writer(sys.stdout, delimiter=',')
  
  data = np.array([ [3, 7, 9],
                 [1, 7, 0],
                 [4, 12, 8]])
  
  csvToSend.writerows(data)
  </code></pre>
  
  <p>The python-script is currently simulating a camera sending picture in bgr RAW format.</p>
  
  <p>The piped data is received by my C++ code, this is how the code looks for the moment:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;opencv2/core/core.hpp&gt;
  
  using namespace std;
  using namespace cv;
  
  string values = "", csvPart;
  Mat img;
  int i;
  
  int main()
  {
      for (i = 0; i &lt; 3; i++)
      {
  
          cin &gt;&gt; csvPart; //here I get my CSV lines from python-script
  
          if (values == "") values = values + csvPart;
  
          else values = values + "\n" + csvPart;  //makes the CVS lines look like a 3x3 matrix again
      }
  
      cout &lt;&lt; values &lt;&lt; endl; //prints the CVS to see that it looks like it did before piping it over to the C++ code
  
      /* how the printed string looks like
      3,7,9 
      1,7,0
      4,12,8    */
  
  /*      Here I want to load the "values" into the Mat img
          so I can do my mojo with openCV in C++          */
  }
  </code></pre>
  
  <p>It would be much appreciated if someone could help me out with this and give me a simple code example. 
  If there is a better way of piping the np.array over to the C++ code and load it into a cv::Mat my arms are open for you! ;-)</p>