I've used the script below to make some under/over exposures in low light levels using the PiCamera HQ and the picamera
module.
In order to get long exposure times I've found that the camera
object must be initiated with a low frame rate. For example, a rate of 3 frames per second allows exposure times as long as roughly 1/3 of a second.
However, I am not able to make exposures that last longer than 1/3 of a second. Even if I set the frame rate to 1 or 0.1 per second, they are limited to 1/3 sec.
In this case if the longer exposure times are set to values greater than about 1/3 of a second, the exposure happens but is limited to 1/3 of a second probably by the fps
which can not be successfully set to numbers below 3 per second.
I do understand that raising camera.iso
will make the 1/3 sec exposures brighter looking probably by increasing the ADC gains1 in the camera, but for my needs I really need the integration time. I need the photons.
One workaround is to make a slightly discontinuous integration using .capture_continuous()
which will generate a number of images that can be stacked. But I'd still like to try for longer single exposures.
Question: How to expose for longer than 1/3 of a second with PiCamera HQ using picamera?
I know that the camera itself is capable of it, the following command typed in the terminal successfully generates and saves a 10 second (10 million microsecond) exposure:
raspistill -t 10 -bm -ex off -ag 1 -ss 10000000 -st -o filename.jpg
1apparently there are both digital and analog gain settings inside the camera itself.
Potentially helpful resources:
- Getting Started; Raspberry Pi HQ Camera
- Documentation Basic Recipes
- Documentation API - picamera.camera Module
- The Official Raspberry Pi Camera Guide
My test scrip:
from time import sleep
from picamera import PiCamera
camera = PiCamera(resolution=(2028, 1520), framerate=3) # going lower makes no difference
camera.iso = 100 # Set ISO to the desired value
sleep(2) # Wait for the automatic gain control to settle
camera.shutter_speed = camera.exposure_speed # fix exposure to "optimum"
camera.exposure_mode = 'off'
sp = camera.shutter_speed # save
g = camera.awb_gains
camera.awb_mode = 'off' # fix auto white ballance gains
camera.awb_gains = g
speeds = [sp >> 2, sp >> 1, sp, sp << 1, sp <<2] # under/over
for i, speed in enumerate(speeds):
camera.shutter_speed = speed
filename = 'test_' + str(10000+i)[1:] + '.png'
my_file = open(fname, 'wb')
camera.capture(my_file)
my_file.close()