新的,我正在使用spinnaker SDK示例用于Flir(PointGrey(相机。我正在尝试将"转换图像"转换为Windows表单中的Picture Box中,并获得错误"无法将类型隐式转换为'System.Drawing.Image'。存在明确的转换(您是否缺少铸件?("。你能给我一个想法我需要做什么吗?谢谢!
尝试了所有内容,包括基本的显式演员。
//Part of Spinnaker SDK example:
using (IManagedImage convertedImage =
rawImage.Convert(PixelFormatEnums.Mono8))
{
String filename = "TriggerQS-CSharp-";
if (deviceSerialNumber != "")
{
filename = filename + deviceSerialNumber + "-";
}
Image testImage = convertedImage;
}
我也有同样的问题。Spinnaker类型IManagedImage
具有称为ManagedData
的属性,该属性是一个1D向量,其中包含图像的所有字节。如果您的颜色如下我的示例中,它们是交错的。
//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);