waveform80 / picamera

A pure Python interface to the Raspberry Pi camera module
https://picamera.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.56k stars 358 forks source link

Jumping exposure time on Raspberry Pi HQ camera #712

Open M-Enderle opened 2 years ago

M-Enderle commented 2 years ago

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:

I am running

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

Bra1nsen commented 2 years ago

hey nice project, did you solve it?

moreover do you pherahbs know how to set the exposure time below 1ms ( for example 0.1ms)

Traceback (most recent call last): File "/home/pi/kotzmichan.py", line 39, in <module> camera.shutter_speed = 0.5 File "/usr/lib/python3/dist-packages/picamera/camera.py", line 2594, in _set_shutter_speed self._camera.control.params[mmal.MMAL_PARAMETER_SHUTTER_SPEED] = value File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 1493, in __setitem__ func(self._port, key, conv(value)), ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type