In my code, I get WriteableBitmaps from an array of bytes (in turn, from Kinect), and I would like to turn them into bitmaps for use with EmguCV. This is currently the code that I have:
// 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, 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));
I got the bottom half of the code here . The compilation of the code is all, but it freezes when I try to run the program (it needs to perform some operations with the image, and then convert it to a format that can be represented as an image.) By pausing my code and then using IntelliTrace in VS 2013, I I get the following exception when Image<Gray, Byte> img = new Image<Gray, Byte>(b); "Fixed System.ArgumentException: URI format is not supported." Using alternative code, from where I go directly from bytes to a bitmap, gives me the same error. ( The code can be found here. )
Has anyone got any tips on how to resolve this error, or alternative ways to cast to bitmaps? I am new to C # and EmguCV, and I would really appreciate it.
c # bitmap kinect emgucv writeablebitmap
Gaessaki
source share