title: Converting Basler image to OpenCV
body: <p>I'm trying to convert frames captured from a Basler camera to OpenCV's Mat format. There isn't a lot of information from the Basler API documentation, but these are the two lines in the Basler example that should be useful in determining what the format of the output is:</p>
  
  <pre><code>// Get the pointer to the image buffer
  const uint8_t *pImageBuffer = (uint8_t *) Result.Buffer();
  cout &lt;&lt; "Gray value of first pixel: " &lt;&lt; (uint32_t) pImageBuffer[0] &lt;&lt; endl &lt;&lt; endl;
  </code></pre>
  
  <p>I know what the image format is (currently set to mono 8-bit), and have tried doing:</p>
  
  <pre><code>img = cv::Mat(964, 1294, CV_8UC1, &amp;pImageBuffer);
  img = cv::Mat(964, 1294, CV_8UC1, Result.Buffer());
  </code></pre>
  
  <p>Neither of which works. Any suggestions/advices would be much appreciated, thanks!</p>
  
  <p>EDIT: I can access the pixels in the Basler image by:</p>
  
  <pre><code>for (int i=0; i&lt;1294*964; i++)
    (uint8_t) pImageBuffer[i];
  </code></pre>
  
  <p>If that helps with converting it to OpenCV's Mat format.</p>