|
MJPEG Decoder
Last year the Coding4Fun/Channel 9 guys asked me to work on a few things for MIX10. One of these items was a way to output a webcam stream to Windows Phone 7 for use with Clint’s t-shirt cannon project you may have read about. I figured the easiest way to accomplish this was by using a network/IP camera capable of sending a Motion-JPEG stream, which can be easily decoded and displayed that can display a JPEG image. Thus, this library was born.It has gone through quite a few changes and I have expanded it to easily display MJPEG streams on a variety of platforms. The developer just references the assembly appropriate to their platform, adds a few lines of code, and away it goes.UsageFor those that are just interested in the usage, it's as simple as this:Reference one of the following assemblies appropriate for your project: MjpegProcessorSL.dll - Silverlight (Out of Browser Only!) MjpegProcessorWP7.dll - Windows Phone 7 (XNA or Silverlight, performance maxes out around 320x240 @ 15fps, so set your camera settings accordingly) MjpegProcessorXna4.dll - XNA 4.0 (Windows) MjpegProcessor.dll - WinForms and WPF Create a new MjpegDecoder object. Hook up the FrameReady event. In the event handler, take the Bitmap/BitmapImage and assign it to your image display control: In the case of XNA, use the GetMjpegFrame method in the Update method, which will return a Texture2D you can use in your Draw method. Call the ParseStream method with the Uri of the MJPEG "endpoint". That's it! The source code and binaries above both include projects demonstrating how to use the library on each of these platforms. As long as you set the appropriate reference, you can just copy and paste the code in the sample to get your project running (changing the Uri, of course).public partial class MainWindow : Window { MjpegDecoder _mjpeg; public MainWindow() { InitializeComponent(); _mjpeg = new MjpegDecoder(); _mjpeg.FrameReady += mjpeg_FrameReady; } private void Start_Click(object se...
Video Length: 0
Date Found: February 10, 2011
Date Produced: February 10, 2011
View Count: 9
|