How to stop a running exposure? #589
-
First of all many thanks for providing this great software! I use picamera2 for astro-photography. For these applications I am only interested in the raw Bayer data. It is typical to have extreme long exposure times (minutes!). In some situations it is needed to reconfigure or restart the camera. But when the camera was already started with a long exposure time the import time
from picamera2 import Picamera2
from libcamera import controls
print('Opening and configuring camera...')
picam2 = Picamera2()
config = picam2.create_still_configuration(
queue=False,
buffer_count=1
)
config["main"]["size"] = (240, 190)
config["raw"] = {"size": (4056, 3040), "format": 'SRGGB12'}
picam2.align_configuration(config)
picam2.configure(config)
picam2.set_controls(
{
# controls for main frame: disable all regulations
"AeEnable": False, # AEC/AGC algorithm
# disable noise reduction in main frame because it eats stars
"NoiseReductionMode": controls.draft.NoiseReductionModeEnum.Off,
# disable automatic white balance algorithm and set colour gains manually
"AwbEnable": False,
"ColourGains": (2.0, 2.0), # to compensate the 2 G pixel in Bayer pattern
# low level controls
"AnalogueGain": 20,
"ExposureTime": int(60 * 1e6), # 1 minute
# exposure time in us; needs to be integer!
}
)
StartTime = time.time()
print(f'Starting camera at T=0s')
picam2.start()
time.sleep(1.0)
print(f'Found that I need to stop camera at T={time.time() - StartTime:.2f}s')
picam2.stop()
print(f'Camera stopped at T={time.time() - StartTime:.2f}s') It generates this output:
You can see that I call In such situations the running exposure will anyway thrown away. Waiting until the end of the exposure is a wast of time. Is there a way to stop the camera faster? Can I use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, thanks for the question. When the camera is running, we normally delegate camera-related operations to the event loop which is why the "official" In the meantime, I would expect that what you're doing will probably be OK so long as there aren't any other camera operations in progress and you wait a few moments before doing anything else. Though this seems a slightly grey area! |
Beta Was this translation helpful? Give feedback.
Hi, thanks for the question.
When the camera is running, we normally delegate camera-related operations to the event loop which is why the "official"
picam2.stop()
has to wait for the event loop to run again (when a frame turns up). This is probably something we could review for a future release.In the meantime, I would expect that what you're doing will probably be OK so long as there aren't any other camera operations in progress and you wait a few moments before doing anything else. Though this seems a slightly grey area!