【问题标题】:Convert byte[] to Image EmguCV without know width and height在不知道宽度和高度的情况下将 byte[] 转换为 Image EmguCV
【发布时间】: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;

你能帮帮我吗?

【问题讨论】:

    标签: java image emgucv


    【解决方案1】:

    我发现了这个 [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 图像的构造函数。

    【讨论】:

    • 工作正常!!!但有必要将图像添加到位图为:Bitmap returnImage = (Bitmap)Image.FromStream(ms);
    猜你喜欢
    • 2012-05-04
    • 2013-12-01
    • 2012-08-20
    • 2012-05-28
    • 2016-12-29
    • 2012-04-17
    • 2021-03-08
    • 2016-08-30
    • 1970-01-01
    相关资源
    最近更新 更多