在不知道宽度和高度的情况下将 byte[] 转换为 Image EmguCV
Convert byte[] to Image EmguCV without know width and height
我需要在不知道宽度和高度的情况下将字节数组 (byte[]
)(从 java BufferedImage
)转换为 EmguCV 图像。
byte[] bytes = [data];
Image<Gray, byte> image = new Image<Gray, byte>();
image.Bytes = bytes;
你能帮帮我吗?
我找到了这个
[ http://www.emgu.com/forum/viewtopic.php?t=1057 ]
public Image<Bgr, Byte> byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Bitmap returnImage = Image.FromStream(ms);
return new Image<Bgr, byte>(returnImage);
// you probably need to clean up stuff like the bitmap and the stream...
}
在 emgu 论坛上重新输入以删除变量名拼写错误。假设您的字节数组是一个标准图像,看起来您可以将它加载到一个标准图像变量中,该变量将自动确定大小。从那里您可以将该图像传递给 emgu 图像的构造函数。
我需要在不知道宽度和高度的情况下将字节数组 (byte[]
)(从 java BufferedImage
)转换为 EmguCV 图像。
byte[] bytes = [data];
Image<Gray, byte> image = new Image<Gray, byte>();
image.Bytes = bytes;
你能帮帮我吗?
我找到了这个 [ http://www.emgu.com/forum/viewtopic.php?t=1057 ]
public Image<Bgr, Byte> byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Bitmap returnImage = Image.FromStream(ms);
return new Image<Bgr, byte>(returnImage);
// you probably need to clean up stuff like the bitmap and the stream...
}
在 emgu 论坛上重新输入以删除变量名拼写错误。假设您的字节数组是一个标准图像,看起来您可以将它加载到一个标准图像变量中,该变量将自动确定大小。从那里您可以将该图像传递给 emgu 图像的构造函数。