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 Emu.CV.Image
without first converting it to a System.Drawing.Bitmap
.
So far, this constructor for Image
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 TDepth[,,] data
argument.
Here's what I have so far:
// 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<Gray, Byte> depthImage = new Image<Gray, Byte>([depthBitmap.PixelHeight, depthBitmap.pixelWidth, depthPixelData]);
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 TDepth[,,]
object with my pixel data to pass in to the Image
constructor.
This code needs to run at ~30fps, so I'm trying to be as efficient as possible with object creation, memory allocation, etc.
depthImage.Data[x, y] =
is roughly 10x slower than this). – Sprawl