Questions about accessing the exposure time through DirectShow
Up to Table of Contents
Technical background
UVC compatible cameras expose the exposure time to the operating system through the so-called Exposure Time (Absolute) Control on the Camera Terminal. There is a second control, the Exposure Time (Relative) Control, however it is not currently implemented by any Logitech UVC cameras. The value of the Exposure Time (Absolute) Control is expressed in units of 100 μs, i.e. 1 is 1/10,000th of a second, 100 is 1/100th of a second, 10,000 is 1 second, 100,000 is 10 seconds, and so on.
Microsoft Windows exposes the exposure time through the DirectShow IAMCameraControl interface, notably its CameraControl_Exposure control. The value of the CameraControl_Exposure control is expressed in log base 2 seconds. This means that for negative values the exposure time is 1/2|n| seconds and for positive values the exposure time is 2n seconds. For example: -10 is a 1/1024th of a second, -4 is a 1/16th of a second, -1 is half a second, 0 is one second, 1 is 2 seconds, and 4 is 16 seconds.
The problem
There are a series of problems caused by the fact that UVC cameras and DirectShow use different ranges and units.
The first one is that the limited granularity of the DirectShow property does not allow applications to take full advantage of the exposure time control that the camera actually provides.
The second one is that the mapping between the two cannot be done in an exact way. The attempt to set the DirectShow control to -10 (1/1024 s) leaves the driver with the choice whether to map this to 9 or 10 since the exact conversion of 1/1024 s to UVC units would be 9.765625 (1/1024 s = 0.0009765625 s = 976.5625 μs = 9.765625 * 100 μs).
The same problem happens the other way round. What if the camera's current internal exposure time is 0.01 s? When the driver reads the UVC control it sees 100 (0.01 s = 10,000 μs = 100 * 100 μs). The two closest DirectShow values are -7 (1/128 s = 0.0078125 s) and -6 (1/64 s = 0.015625 s), both of which are quite far apart from the actual value.
Finally, it is not possible for applications to get or set the exposure time in seconds (or decimal fractions thereof). Dealing with the exposure time often involves working with fractions.
Logitech implementation
General
The Logitech UVC generally supports the IAMCameraControl interface and the CameraControl_Exposure control. However, the implementation suffers from a series of issues that limit its usefulness in versions up to QuickCam 11.8. The next section explains these issues in more detail.Auto-exposure
The Logitech UVC driver disables auto-exposure when an application programmatically sets the exposure time.
Known issues
Wrong mapping
To make matters even more complicated than described above the Logitech UVC driver's filter property page contains an exposure time slider with values given as fractions of a second. Unfortunately, this mapping has been wrong and inconsistent for a long time. The following table summarizes the property ranges supported by the last few software releases, together with the correct values and the values that the slider on the property page takes on when a given DirectShow value is set. QC stands for Logitech QuickCam and LWS for Logitech Webcam Software, the successor of QuickCam.
| DirectShow value [2n s] |
QC 11.5 [s] | QC 11.7/11.8 [s] | QC 11.9 [s] |
LWS 1.0 [s] |
Correct [s] |
|---|---|---|---|---|---|
| -14 |
1/15 |
n/a | n/a | n/a | 1/16384 |
| -13 |
1/5 |
1/819 |
n/a | n/a | 1/8192 |
| -12 |
1/5 | 1/410 |
n/a | n/a | 1/4096 |
| -11 |
1/5 | 1/205 |
n/a | n/a | 1/2048 |
| -10 |
1/5 | 1/102 |
n/a | n/a | 1/1024 |
| -9 |
1/5 | 1/51 |
1/512 |
1/512 |
1/512 |
| -8 |
1/5 | 1/26 |
1/256 |
1/256 |
1/256 |
| -7 |
1/8 |
1/13 |
1/128 |
1/128 |
1/128 |
| -6 |
1/16 |
1/6 |
1/64 |
1/64 |
1/64 |
| -5 |
1/31 |
1/5 |
1/32 |
1/32 |
1/32 |
| -4 |
1/63 |
1/5 | 1/16 |
1/16 |
1/16 |
| -3 |
1/125 |
1/5 | 1/8 |
1/8 |
1/8 |
| -2 |
1/250 |
1/5 | 1/5 |
1/5 |
1/4 |
| -1 |
1/500 |
1/5 | n/a | 1/5 |
1/2 |
| 0 |
1/5 |
1/5 | n/a | 1/5 |
1 |
Note that the value -14 corresponds to an exposure time that is shorter than what the UVC specification minimally allows. It is therefore not supported by newer implementations. The values -13 to -10 are not supported by most cameras and therefore listed as not available. The values -1 and 0 are not supported by most cameras, but LWS 1.0 includes them in the property range because they are (erroneously) reported as valid by the device.
Device unit
All Logitech UVC cameras have a wrong and inverted absolute exposure time property range in hardware. The range is reported as [0.0001 s, 1 s] but the values are interpreted in a way that a UVC property value of 0.n [s] actually means 1/n [s]. The following table shows the relation between the set DirectShow value, the value displayed in the filter property page of Logitech Webcam Software 1.0, and the value sent to the device. The last column contains the approximate value that is used by the device.
| DirectShow value [2n s] |
LWS 1.0 [s] |
UVC value [s] | Device interpretation [s] |
|---|---|---|---|
| -9 |
1/512 |
0.512 | 1/512 |
| -8 |
1/256 |
0.256 | 1/256 |
| -7 |
1/128 |
0.128 | 1/128 |
| -6 |
1/64 |
0.064 | 1/64 |
| -5 |
1/32 |
0.032 | 1/32 |
| -4 |
1/16 |
0.016 | 1/16 |
| -3 |
1/8 |
0.008 | 1/8 |
| -2 |
1/5 |
0.004 |
1/4 |
| -1 |
1/5 |
0.002 |
1/4 |
| 0 |
1/5 |
0.001 |
1/4 |
This particularity is only visible when using a non-Logitech UVC driver, such as the generic UVC drivers that come with Windows, Linux, or other operating systems.
The Logitech UVC driver that ships as part of QuickCam 11.5 erroneously returns the HRESULT error value 0x80070032 ("The request is not supported") when attempting to set the exposure time value. In reality, the request succeeds as can be verified by simultaneously observing the filter property page.
Status and outlook
Starting with QuickCam 11.90 and Webcam Software 1.0 the most serious software issues have been resolved. Future hardware generations are likely to resolve the remaining issue with the unit of the exposure time property.
To work around the limited granularity and the rounding problems of the CameraControl_Exposure control a new property called KSPROPERTY_LP1_EXPOSURE_TIME was introduced as part of the Logitech Public Property Set, which is a new feature of Webcam Software 1.0. This property has a unit of 100μs and therefore allows proper mapping to the UVC exposure time property.
This page will be updated accordingly whenever more information is available.