Pi HQ Camera vs DSLR image fidelity

Well, you have triggered old memories here (which I was obviously trying to forget…). Citing myself,

" Another important deviation from the old picamera-lib is the handling of digital and analog gain. In the new picamera2-lib, there is actually no way to set digital gain. As the maintainer of the library explained to me, a requested exposure time is realized internally by choosing an exposure time close to the value requested and an appropriate multiplicator to give the user an approximation of the exposure time requested.

An exposure time of, say, 2456 is not realizable with the HQ sensor hardware. The closest exposure time available (due to hardware constraints) is 2400. So the requested exposure would be realized in libcamera/picamera2 by selecting: (digital gain = 1.0233) * (exposure time = 2400) = (approx. exposure time = 2456)."

and

“One approach to circumvent this is to choose exposure times which are realizable hardware-wise and request this exposure time repeatably (thanks go to the maintainer of the new picamera2-lib for this suggestion), until the digital gain has settled to 1.0. For example, the sequence 2400, 4800, 9600, etc. should give you in the end a digital gain = 1.0. And usually, it takes between 2 and 5 frames to obtain the desired exposure value.”

I think one way to figure out which exposure times are directly realizable with the hardware is to request a certain exposure and monitor the digital gain which is returned in the metadata. Due to an automated process running in the background of libcamera, you will need to capture at least 10-20 consecutive frames before you read out the value of the digital gain. If it’s close to 1.0, you have found one exposure time you are after.

Note: this was the status about 2 years ago. There has been work done on this, so things might have changed. Never bothered to check again - libcamera and picamera2 are technically speaking a mess and overall a rather bad design. And the libcamera people as well as the RP guys tend to change things happening under the hood without much information towards the user. That’s why I am very hesitant updating these two software packages once I have a running/working system.

Let me note that questions about picamera2 can be posted here. The maintainer of the picamera2-library is rather responsive and helpful. Also, searching the “Closed” issues you might discover some useful information.

Update: I had a discussion with David Plowman, the maintainer of picamera2, about the current state of affairs (Sep '24). According to him, DigitalGain is only applied “to the fully processed ISP output”. It is not applied to the raw output. So DigitalGain is relevant only if you store rec709-like images as .jpg or .png, for example. In case of linear raw files (.dng), only the AnalogGain gets applied. So, if you are working with raw files, no need to worry about the DigitalGain-value. And of course, you should set AnalogGain = 1.0 for the lowest noise level.