New to this, I'm using Spinnaker SDK example for a FLIR (PointGrey) camera. I'm trying to convert the 'convertedImage' for use in a PictureBox in Windows Forms and get an error "Cannot implicitly convert type to 'System.Drawing.Image'. An explicit conversion exists (are you missing a cast?)". Can you give me an idea what I need to do? Thanks!
Tried everything including basic explicit casts.
//Part of Spinnaker SDK example:
using (IManagedImage convertedImage =
rawImage.Convert(PixelFormatEnums.Mono8))
{
String filename = "TriggerQS-CSharp-";
if (deviceSerialNumber != "")
{
filename = filename + deviceSerialNumber + "-";
}
Image testImage = convertedImage;
}
I had the same problem. The Spinnaker type IManagedImage
has a property called ManagedData
, which is a 1d vector containing all the bytes of your image. If you have colors as in my example below, they are interleaved.
//cv.ManagedData is a one D array of all pixels in all colors
int nx = 2592;
int ny = 1944; //7776/3 = 2592 stride, i.e. rgb are interleaved
byte[,,] data = new byte[ny, nx, 3];
for (int j = 0; j < ny; j++)
{
for (int i = 0; i < nx; i++)
{
for (int k = 0; k < 3; k++)
{
data[j,i, k] = cv.ManagedData[j * 3 * nx + 3 * i + k];
}
}
}
//emgu cv accepts the [,,] byte array
Image<Bgr, Byte> im0 = new Image<Bgr, Byte>(data);