在我的代码中,我从字节数组(依次从Kinect)接收WriteableBitmaps,我想把它们变成用于EmguCV的位图.目前这是我的代码:
// copy the pixel data from the image to a temporary array colorFrame.copyPixelDataTo(this.colorPixels); // Write the pixel data into our bitmap this.colorBitmap.WritePixels( new Int32Rect(0,this.colorBitmap.PixelWidth,this.colorBitmap.PixelHeight),this.colorPixels,this.colorBitmap.PixelWidth * colorFrame.BytesPerPixel,0); BitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(colorBitmap)); MemoryStream ms = new MemoryStream(); encoder.Save(ms); Bitmap b=new Bitmap(ms); Image<Gray,Byte> img = new Image<Gray,Byte>(b); img = img.ThresholdBinary(new Gray(200),new Gray(255));
我从here获得了代码的下半部分.代码编译和所有内容,但是在我尝试运行程序时挂起(它应该对图像执行一些操作然后将其转换回可以呈现的格式作为一个图像.)暂停我的代码,然后在VS 2013中使用IntelliTrace,我在Image< Gray,Byte>处获得以下异常: img = new Image< Gray,Byte>(b); “抛出了System.ArgumentException:不支持URI格式.”使用替代代码,从我直接从字节到位图的位置给出了同样的错误. (Code can be found here.)
解决方法
原文地址:https://www.jb51.cc/csharp/99723.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。