[Wiki] Motion JPEG

Motion JPEG, also known as MJPEG, is a video codec which saves every single frame as jpeg image.
In contrary to videos which are comprimized with MPEG codecs where, among other things, only the frame differences are stored, in MJPEG videos the whole frames are saved as separately jpeg images.  This brings advantages as also disadvantages with it.
On the one hand there are no artefacts in fast video sequences/scenes but on the other hand you get much larger video files because much more image information has to be stored. For a video in SVHS-quality, which is saved in MJPEG format, you need round about 25 MBit (3,1 MByte) per second.
MJPEG encoded video material can be found today usually only in the ip-cam sector.  (ip-cam = network camera) For network cameras the MJPEG codec seems to be ideal, because it needs hardly any hardware resources for encoding the video and nearly every […]

New category – “wiki”

 
Hello together,
I’ll just want to inform you that there’ll be soon a new category. The category will be named “wiki” and gradually filled with articles, which on the contrary to my other articles on this blog, will completely missing my personal touch. The articles should be seen as pure knowledge articles which are totally free from any comments of mine or my personal opinion.
If you now ask yourself, “Why does he do that?” I’ll say, “let me explain it to you.” A couple of times there have been articles where I used techniques and terms whiche are not very common. So as not to bloat these articles with all that nerdy stuff, I will create wiki articles on specific topics, which you can work through, to get the necessary background knowledge for the main articles.
 
 
Greetings,
Raffi

How to easily record from a webcam in C#

What is the easiest way to use a webcam in C# and record from it? If you search for an answer to this question you’ll find a lot of articles in the internet but most of them are many pages long and very confusing. However that isn’t really necessary. With the aid of the AForge.NET library you can do the given task really easy. Just a few lines of C# code are enough to drive your webcam and capture images from it. In the following I’ll show you how to handle the AForge library.
What do you need?

The AForge.Video.dll together with the AForge.Video.DirectShow.dll
Both dlls can be found on the AForge website inside the “(libs only)” zip-archive.
A simple winforms-application, with a picturebox on its gui
A webcam. For example this one:No products found.
Basic C#-knowledge. If not exists, read this: No products found.

At first you have to reference the both dlls and write the using-statements […]

Compress images with jpeg codec in C#

Today I’ll show you how to compress your images with help of the JPEG-codec in C#. You will be able to choose the grade of compression. So it’s your choice, if the function should produce smaller filesize or better quality of images.

private void CompressImage(Image sourceImage, int imageQuality, string savePath)
{
try
{
//Create an ImageCodecInfo-object for the codec information
ImageCodecInfo jpegCodec = null;

//Set quality factor for compression
EncoderParameter imageQualitysParameter = new EncoderParameter(
System.Drawing.Imaging.Encoder.Quality, imageQuality);

//List all avaible codecs (system wide)
ImageCodecInfo[] alleCodecs = […]

Capture a complete website in C#

To take a screenshot is one thing. One click on the print key or a small program, which uses the c# screenshot capture method, I showed you the last time, are enough to take a beautiful screenshot.
But what should you do, if you want to capture a whole website? The most websites are “longer” as your screen is high. Thereby most common ways to capture a screenshot will become useless.
But don’t fear – C# can of course solve this problem. If you want to capture a screenshot of a complete website, take a look at the following snippet.

private void WebsiteScreenshot(string url, string file)
{
//Create a webbrwoser object
WebBrowser browser = new WebBrowser();

//Deactivate scrollbars, unless you want them to
//appear on your screenshot
browser.ScrollBarsEnabled = false;

[…]