Last active
April 13, 2023 14:55
-
-
Save hessammehr/8792afa33933b423ecee492f88ff7223 to your computer and use it in GitHub Desktop.
Low light acquisition script for old picamera (raspistill, etc.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import logging | |
import time | |
import picamera | |
from fractions import Fraction | |
EQUILIBRATION_SECONDS = 10 | |
argparser = argparse.ArgumentParser() | |
argparser.add_argument( | |
"--exposure", | |
"-e", | |
type=int, | |
help="Exposure time in seconds (max 16)", | |
default=4, | |
) | |
argparser.add_argument( | |
"--iso", | |
"-i", | |
type=int, | |
help="ISO value (max 800)", | |
default=100, | |
) | |
argparser.add_argument( | |
"output", | |
type=str, | |
help="Output file", | |
) | |
args = argparser.parse_args() | |
exposure_seconds = args.exposure | |
output_file = args.output | |
iso = args.iso | |
logging.info("Equilibrating camera for %s seconds", EQUILIBRATION_SECONDS) | |
p = picamera.PiCamera(framerate=Fraction(1, exposure_seconds)) | |
p.shutter_speed = exposure_seconds * 1000000 | |
p.iso = iso # max 800 | |
time.sleep(EQUILIBRATION_SECONDS) | |
p.exposure_mode = "off" | |
logging.info("Capturing for %s seconds", exposure_seconds) | |
p.capture(output_file) | |
p.close() | |
logging.info("Done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment