title: Convert a string of bytes to cv::mat
body: <p>I need to implement a function that <strong>receives a string containing the bytes of an image</strong> (received via boost socket connection) and <strong>converts</strong> the info into an <strong>OpenCV cv::Mat</strong>.</p>
  
  <p>I also know the width and height of the image and its size in bytes. My function looks like this:</p>
  
  <pre><code>void createImageFromBytes(const std::string&amp; name, std::pair&lt;int,int&gt; dimensions, const std::string&amp; data)
  {
     int width,height;
     width = dimensions.first;
     height = dimensions.second;
     //convert data to cv::Mat image
  
     std::string filepng = DATA_PATH"/" + name +".png";
     imwrite(filepng, image);
  }
  </code></pre>
  
  <p>Which is the best method for doing this? Does OpenCV has a constructor for Mat from a string?</p>