I'm using the StreamRecorder Sample from the Microsoft Hololens2ForCV Repository to access the rgb & depth frames from the Hololens 2. One change I need to make to the samplecode, specifically to the rgb camera recorder (called VideoFrameProcessor.cpp in the sample), is that the auto exposure needs to be turned off, and the exposure time should be set to a specific duration. So far I have not been able to accomplish this - I've just managed to turn off the auto exposure, but not to set the desired value, which means that every time I start the app I get a slightly different exposure time, depending on where the rgb camera is initially looking.
I tried variations of the following code, inserted in the VideoFrameProcessor::InitializeAsync method, after the MediaCapture has been initialized:
auto exposureControl = mediaCapture.VideoDeviceController().ExposureControl();
if (exposureControl.Supported())
{
co_await exposureControl.SetAutoAsync(false);
co_await exposureControl.SetValueAsync(winrt::Windows::Foundation::TimeSpan(100000));// 10 ms
}
else
{
// log failure message into a logfile
}
however, this does not have the intended effect, as the auto exposure is still enabled. I tried different versions of this, including swapping the order of the instructions so that the exposure time is set first, and auto exposure is turned off afterwards, which did not change the outcome. The best I can do is disable auto exposure by just calling exposureControl.SetAutoAsync(false) - but then, as soon as I try to set the exposure time via SetValueAsync, the auto exposure is turned on again & my value is ignored.
After spending some more time on the issue, I found the cause of the problem: The code I posted actually works as intended, however there is another camera setting that interferes with how bright the captured images look - namely, the ISO speed. ISO speed is a variable independent of the exposure, and thus allows one to change picture brightness without changing the exposure settings. The IsoSpeedControl has a setting that auto-adjusts the ISO speed to the lighting conditions, which on the hololens 2 is apparently turned on by default. So, if one does not know that this setting exists and captures a sequence of images with auto-exposure turned off and a fixed exposure time, it may look as if the auto-exposure were still turned on.
I used the following code snipped to control the ISO speed: