title: How to use cv::imencode on IplImage?
body: <p>I have an image saved in a variable fo type IplImage like this:</p>
  
  <pre><code>IplImage* fIplImageHeader;
  fIplImageHeader = cvCreateImageHeader(cvSize(width, height), 8, 3);
  fIplImageHeader-&gt;imageData = (char*) memblock;
  </code></pre>
  
  <p>How can I use the cv::imencode function on that image?</p>
  
  <p>cv:imencode looks like this:</p>
  
  <pre><code>bool imencode(const string&amp; ext, const Mat&amp; img, vector&lt;uchar&gt;&amp; buf, const vector&lt;int&gt;&amp; params=vector&lt;int&gt;())
  </code></pre>
  
  <p>So obviously I need to convert IplImage to const Mat somehow but I cannot find how to do that in the documentation.</p>
  
  <p>What should I do?</p>
  
  <p>This does not work of course:</p>
  
  <pre><code>cv::imencode("JPG", fIplImageHeader, fIplImageHeader);
  </code></pre>