Skip to content

Instantly share code, notes, and snippets.

@thomasweng15
Created January 14, 2015 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasweng15/b3e84805be1c832fd534 to your computer and use it in GitHub Desktop.
Save thomasweng15/b3e84805be1c832fd534 to your computer and use it in GitHub Desktop.
Converting byte array back into iplimage
BitmapSource bitmap = BitmapSource.Create(
640, 480,
96, 96, pf, null,
buffer, rawStride);
// save image to stream
MemoryStream ms = new MemoryStream();
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Save(ms);
ms.Seek(0, SeekOrigin.Begin);
// load as a System.Drawing.Bitmap
System.Drawing.Bitmap b = new System.Drawing.Bitmap(ms);
IplImage ipl = b.ToIplImage();
Cv.ShowImage("Object Segmentation", ipl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment