2

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:

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()
7
  • 1
    Care to explain why you do not want to go for stacking? If "getting them photons" is the goal, stacking should do fine (except of course w.r.t. the issue that HeatfanJohn reported).
    – Ghanima
    Oct 5, 2021 at 5:58
  • @Ghanima that's a very good point. I'll mention a couple of things: 1) I'm simply curious what's causing this apparent limit because I like to understand things; is it something in the picamera module, the camera's firmware, the hardware, something else, etc. 2) for static views that might work but if you are looking at trails of some kind (star trails through a telescope, an LED on a pet, an art project) you'd prefer a continuous exposure, the stacking would cause un-aesthetic or data-corrupting interruptions...
    – uhoh
    Oct 5, 2021 at 6:18
  • @Ghanima 3) Astronomers (who push CCDs to their noise limits) definitely use stacking but most aggressively when there are bright objects in the same field as very dim objects; they stack such that the brightest pixels fill up to say 90% of their charge limit to avoid saturation effects. In scientific cases where you have very low levels of light, there's an optimum exposure time that depends on several things including shot noise, ADC noise, etc. One might mildly cool the camera to lower some of these effects. It likely that 1/3 of a second is not the optimal.
    – uhoh
    Oct 5, 2021 at 6:21
  • @Ghanima That said, I do acknowledge that taking a sequence of images might work in my current application if there is not a lot of time overhead between each one. Right now I'm saving as PNG but I plan to migrate to RAW format, so I'll have to look into what options for burst or sequence modes are compatible with those formats. Of course if an answer were posted along those lines it would be most welcome! note: PNG is 8-bits per color, RAW provides access to the full ADC range (10 or 12? bits). I guess increasing ISO lets you spread a weak signal over however many bits you have, but...
    – uhoh
    Oct 5, 2021 at 6:24
  • 1
    I see, thanks for taking the time.
    – Ghanima
    Oct 5, 2021 at 7:22

1 Answer 1

1

I use

raspistill -t 10 -v -md 3 -bm -ex off -ag 1 -ISO 800 -st -ss 2000000 -a 1052

And get a 2 second exposure. I have found that raspistill takes 5 exposures before it takes the exposure that returns an image. This means that call will take 5-6 times the shutter speed. In this case 10 seconds for the 5 exposures you don't see and then 2 seconds for the image returned.

This can be a problem if you're using a really long exposure (astrophotography) as the total time can exceed the maximum time raspistill will allow.

I need to post that as my own question, namely is there a way to disable or reduce those initial exposures or just lower their shutter speed.

enter image description here

2
  • Hmm... this is interesting! I'll go back to see exactly what happened with my 10 second raspistill test. From what I recall it took about 10 or 15 seconds, so perhaps what happened is exactly what happened here; the exposure was actually only 2 seconds long and there were several of them before one was saved.
    – uhoh
    Sep 18, 2021 at 0:33
  • In the case of my script, I set and lock the exposure conditions (exposure time, ADC gains) and then cycle through a set of pre-calculated exposure times. If there's absolutely no way to go slower than 1/3 of a second using PiCamera or any other python script, I suppose I could try to find some way to generate raspistill commands directly from Python and not use any camera package at all, but I'd have to learn more about raspistill to see if I can get those initial settings from raspistill back into python to do the calcualtion.
    – uhoh
    Sep 18, 2021 at 0:38

Your Answer

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

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