0

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?

Roman R.
  • 68,205
  • 6
  • 94
  • 158
Elmi
  • 5,899
  • 15
  • 72
  • 143
  • Mirroring is enabled on camera, or a bug in the driver. Or, your filter graph catches some weird third party buggy filters which alter image prior to its displaying. – Roman R. Apr 23 '13 at 20:30
  • Amazingly it happens with two very different cameras, so I'd guess it is not a driver problem... – Elmi Apr 23 '13 at 20:38
  • May be it is a feature and not a bug: what is the image orientation of the data that are returned by SampleGrabber->GetCurrentBuffer()? May be there the last row comes first in memory? That would explain why it it bottom-top-oriented... – Elmi Apr 24 '13 at 06:38
  • Oh, I thought it's mirrored around the other axis... – Roman R. Apr 24 '13 at 06:41

1 Answers1

1

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.

Roman R.
  • 68,205
  • 6
  • 94
  • 158