title: Convert a byte[] into an Emgu/OpenCV Image
body: <p>I have a byte array representing a greyscale image that I would like to use with openCV in C#, using the Emgu wrapper. I am trying to figure out how to convert this into an <code>Emu.CV.Image</code> without first converting it to a <code>System.Drawing.Bitmap</code>.</p>
  
  <p>So far, <a href="http://www.emgu.com/wiki/files/2.4.2/document/html/84dd94e7-f03f-ceb8-f629-8462326d13a6.htm" rel="noreferrer">this</a> constructor for <code>Image</code> appears promising. It looks like it takes the pixel rows, columns, and then the array with my data to construct an image. However, it wants them in a weird format and I'm struggling with how to correctly construct the <code>TDepth[,,] data</code> argument.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>// This gets initialized in the constructor and filled in with greyscale image data elsewhere in the code:
  byte[] depthPixelData
  
  // Once my depthPixelData is processed, I'm trying to convert it to an Image and this is where I'm having issues
  Image&lt;Gray, Byte&gt; depthImage = new Image&lt;Gray, Byte&gt;([depthBitmap.PixelHeight, depthBitmap.pixelWidth, depthPixelData]);
  </code></pre>
  
  <p>Visual studio is making it obvious to me that just passing in an array isn't going to cut it, but I have no idea how to construct the requisite <code>TDepth[,,]</code> object with my pixel data to pass in to the <code>Image</code> constructor. </p>
  
  <p>This code needs to run at ~30fps, so I'm trying to be as efficient as possible with object creation, memory allocation, etc. </p>