I try to understand how works the gain in OV7725 camera and i am lost without speaking about analog gain.
Firstly, there is the main gain at register address 0x00 which can be used with these both python functions where the gain is in db :
- sensor.set_auto_gain( False, gain_db=(1 to 32db) )
Secondly, there are the 3 white balance gains at register address 0x01 to 0x03 which can be used with these both python functions where the gain is in db :
- sensor.set_auto_whitebal(False, rgb_gain_db=(-42 to 6db for three colors)
I red the c language code, and i did not succeed to understand the equation between db gains and register values ?
Why the ranges are differents for same 8 bits registers ?
I tested to use the main gain in db and i did not succeed to have a good precision.
Here is my code test :
import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.VGA) sensor.skip_frames(time = 500) sensor.set_auto_whitebal(False) sensor.set_auto_exposure(False) gainstart=1 gainstep=0.5 gainend=32 gaindb = gainstart while(True): img = sensor.snapshot() sensor.set_auto_gain(False,gain_db=gaindb) time.sleep(100) getgaindb=sensor.get_gain_db() diff = abs(gaindb - getgaindb) print(diff, gaindb, getgaindb) gaindb += gainstep if gaindb > gainend : gaindb = gainstart
where i can have difference of 2db …
Could you help me to use these gains ?