Question

I'm capturing images from a webcam using code based on the example from http://msdn.microsoft.com/en-us/library/windows/desktop/dd407288(v=vs.85).aspx#example_code

It works fine except one strange thing: the image is mirrored along its x-axis, means it is top-down (but not rotated by 180 degrees).

So how can this happen? Is there a DirectShow option that could cause such a behaviour?

Was it helpful?

Solution

RGB frames typically have reverse order of rows, bottom-to-top. The rule is:

  • RGB Pixel Formats
    • BITMAPINFOHEADER::biHeight > 0 - bottom-to-top rows
    • BITMAPINFOHEADER::biHeight < 0 - top-to-bottom rows
  • YUV Pixel Formats
    • regardless from BITMAPINFOHEADER::biHeight sign (both positive and negative are valid) - top-to-bottom rows

While both positive and negative biHeight values are valid, negative are less spread and supported. Many filters will just reject formats with negative values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top