title: C++ Opencv load CSV file as cv::Mat
body: <p>I save a cv::Mat as a CSV file which works fine, but when I go to load it and convert it back into a cv::Mat something is being corrupted. When I print out the contents of the cv::Mat they are different from that of the csv file. And when I show the Mat object I get a wide white window.</p>
  
  <pre><code>cv::imwrite("cameraFrame1.jpg", frame);
  outFile.open("cameraFrame1.csv");
  outFile &lt;&lt; cv::format(frame, "CSV") &lt;&lt; std::endl;
  outFile.close();
  
  ...
  
  CvMLData mlData;
  mlData.read_csv("cameraFrame1.csv");
  const CvMat* tmp = mlData.get_values();
  cv::Mat img(tmp, true);
  tmp-&gt;CvMat::~CvMat();
  
  std::cout &lt;&lt; "img: " &lt;&lt; img &lt;&lt; std::endl;
  
  cv::namedWindow("img");
  cv::imshow("img", img);
  cv::waitKey(0);
  </code></pre>
  
  <p>Edit:</p>
  
  <p>I am not at all attached to this method, if there is a better way to save an image to CSV and then read it in as such I will gladly move to that. The point of this is to save the image as raw data, most likely in a database, which could then be opened again in matlab, python, c++ etc.</p>