1

I am trying to build a timelapsing program in python, which analyzes the picture and determins the exposure, based on which it corrects it's shutter speed using a polynomial regression.
But I got stuck when the exposure is somewhere around 1 second, where you can see in the graph below, the brightness jumps

x = shutterspeed , y = brightness measured using the PIL histogram

The orange line is the expected curve, the blue dots are actual measurements.

Digging deeper, I found out, that the actual exposure times differs from the shutter speed I set.
With cam.exposure_speed I found out, that at cam.shutter_speed = 1000000 (-> 1s) the actual exposure time was 7997813 (-> 8s) where as at cam.shutter_speed = 990000 (->0.99s) the exposure time was 989976 (-> 0.989s).

Here is an example code to recreate the effect:

from picamera import PiCamera
import time

cam = PiCamera(sensor_mode=2)
cam.framerate = 1/8
cam.iso = 100
cam.shutter_speed = 1000000
cam.resolution = (1600, 900)
time.sleep(5)
cam.capture("test.jpg")
print(cam.exposure_speed)
cam.close()

So far I tested:

  • Diffrent ISO values (needs to fixed ISO)
  • diffrent resolutions
  • removing the sensor_mode argument
  • diffrent framerates

I am running

  • Python 3.7.3
  • Raspberry Pi 4 with 4GB RAM
  • picamera 1.13

Any help on this will be helpful, I will try to edit missing information asap.

1 Answer 1

0

I also struggle with exposure time settings on a regular basis. I even get sometimes different behavior with the same code. (Maybe some internal parameters in the camera might be modified behind the scene).

However, I have good experience by combining consistent values for shutter_speed and frame_rate and setting exposure_mode to 'off'.

E.g. the following code yields a correct exposure time (at least here for me).

from picamera import PiCamera
import time

with PiCamera(sensor_mode=2) as cam:
    exposure_time = 1.0 
    cam.framerate = 1/exposure_time
    cam.iso = 100
    cam.shutter_speed = int(exposure_time*1000000)
    cam.resolution = (1600, 900)
    cam.exposure_mode = 'off'
    time.sleep(5)
    cam.capture("test.jpg")
    print(cam.exposure_speed)
1
  • It seems like the problem was fixed by setting the framerate to 1/exposure_time. The exposure_mode set to 'off' does not change the behaviour. But setting it to 'off' seems like a good idea anyways. Dec 20, 2021 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.