As Roman noted, the default mode for most webcams is MJPEG compression, in order to reduce the data transfer rate that should pass through the USB connection (and, possibly, USB hubs, etc.), and / or maximize the available frame rate / resolution.
For computer vision, this is often undesirable, since we would prefer to have a lower frame rate, but not compression artifacts. In fact, it is possible to generally change the stream format (for example, to uncompressed YUV) in much the same way as, for example, the resolution is changed. Is this possible for you, depends on
- which supports hardware
- which of these modes supports the low-level driver (often a common USB class driver / UVC driver),
- which of the last modes performs it through various frameworks used (for example, video for Windows / DirectX / Video4Linux2, etc.) and
- finally, which one is supported by the video capture backend, is used in OpenCV.
Unfortunately, the answer for the latter is simply none . OpenCV has 18 (!) Different capture servers (for various platforms, for example mobile phones, OS X, Windows and Linux, often several for different versions of the basic frameworks), and although it seems that the API for changing the stream format [1], he, doesn't seem to be implemented by any backend. :-(
If you or someone else wants to work on this, you can check the OpenCV problem that I discovered about this: http://code.opencv.org/issues/3007
In my case, I researched this for some Logitech webcams, which even had different features available with low-level Windows and Linux drivers. On Linux, I unknowingly used the GStreamer OpenCV backend, which means another level of indirection - at the lower level, it always comes down to the V4L kernel API (video for Linux). Using the libv4l backend improved the situation, since it had a nice default property for some YUV stream format (albeit at a lower frame rate, which may be undesirable in other contexts). (There are even different, diverging backends for direct access to the v4l kernel API or through libv4l.)
[1] See CV_CAP_PROP_FORMAT in the API docs: http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html