【发布时间】:2017-06-12 16:34:10
【问题描述】:
我需要在不知道宽度和高度的情况下将字节数组 (byte[])(来自 java BufferedImage)转换为 EmguCV Image。
byte[] bytes = [data];
Image<Gray, byte> image = new Image<Gray, byte>();
image.Bytes = bytes;
你能帮帮我吗?
【问题讨论】:
我需要在不知道宽度和高度的情况下将字节数组 (byte[])(来自 java BufferedImage)转换为 EmguCV Image。
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 图像的构造函数。
【讨论】: