From this and this I know that there is no way of setting camera.analog_gain and camera.digital_gain between subsequent runs of a script. However, I'm still faced with the problem that I need consistent videos between different runs of the same script.
Here's a solution I came up with that I see works if you play around with the light intensity your camera gets and wait. Eventually I get an analog_gain and a digital_gain value that I choose. Except...
Ghetto Solution: #The Value you want for analog_gain = AG #The Value you want for digital_gain = DG AG = Fraction(17, 16) DG = 1 camera=picamera.PiCamera() time.sleep(2) while camera.analog_gain != AG or camera.digital_gain != DG: time.sleep(0.1) print ("analog gain = "+str(camera.analog_gain)) print ("digital gain = "+str(camera.digital_gain)) #time.sleep(2) <=== Don't let the values settle camera.shutter_speed=camera.exposure_speed camera.exposure_mode='off' print (camera.analog_gain) print (camera.digital_gain) g = camera.awb_gains camera.awb_mode = 'off' camera.awb_gains = g camera.shutter_speed = 30000 camera.awb_gains = (1,1) camera.iso = 0
Except, what is the relationship - mathematically - between analog_gain and digital_gain? Is there one? If I have the value for anaolog_gain, what values are possible for digital_gain? What choices for analog_gain and digital_gain are possible or reasonable if I have an experiment where daily I need to wait for the camera gains to settle to the value they were at the previous day?
So far I've just been looking at what values I've seen appear already. e.g. In a previous run I saw
analog gain = 1 digital gain = 17/16
print out and therefore I set
AG = Fraction(17, 16) DG = 1
since I thus knew it was a possible combination. After a while the gains did settle at these values.