DirectShow / WMF (KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE)

AmandaM 1 Reputation point
2020-10-06T01:29:06.24+00:00

*Before I ask my question I need to state that I am primarily a Linux C++ developer and don't have that much experience with writing Windows applications. *

Background

For some time, I have been working on a scientific imaging application which supports various specialist cameras. Most of these cameras have manufacturer supplied SDKs which make development much easier. However, some of the cameras that my application supports are standard UVC cameras. Until recently, my application has been specifically for Linux but is now being ported to macOS and Windows.

  1. The Linux port implements UVC support via Video4Linux and works exceptionally well.
  2. The macOS port implements UVC support via libuvc (https://github.com/libuvc/libuvc) and works very well.

The Problem: Windows UVC Support

I'm having problems implementing UVC cameras on Windows. I have written both DirectShow and a Media Framework processors which work well enough and can control parameters such as gain, brightness, contrast etc just as well as V4L2 which is exactly what I need. However, the problems arise when I try to implement an exposure control.

If I take a specific UVC camera which has a documented exposure range of 1ms to 1000ms then I can use the full exposure range with Video4Linux by using V4L2_CID_EXPOSURE_ABSOLUTE. When the new exposure is applied, I see a nice linear change to the outputted image. I can observe the same when using libuvc on macOS.

When using the same camera on Windows with either DirectShow or Media Foundation the exposure range is very coarse and, frankly unacceptable. The following line of code, as the documentation states, retunes values that are not in real time units. The values are, for example, -11 through to -3 whereas in Video4Linux, these values are in milliseconds.

IAMCameraControl::GetRange(CameraControl_Exposure, min, max, step, value, flags);

From the Microsoft documentation, I can see that using the "KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING" structure with "KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE" I can get exposures in time in 100 nanosecond units.

"KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE " sounds exactly what I need but I am unable to find any documentation that states how to use the "KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING" structure. Does anybody know of any sample programs that clearly show how to use "KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE" to discover the supported exposure in real time units (milliseconds, microseconds, nanoseconds etc) and then apply that exposure to the camera so that I can get a much more linear exposure change?

All help is greatly appreciated.

Amanda

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,502 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,618 questions
{count} votes