summaryrefslogtreecommitdiff
path: root/camera
diff options
context:
space:
mode:
authorStijn Buys <ingar@telenet.be>2024-04-14 15:24:10 +0200
committerStijn Buys <ingar@telenet.be>2024-04-14 15:24:10 +0200
commit6a82d0bf748a057ddf789b32e32d31539cc04460 (patch)
treeb03ca1bf70aac4d379089cf39a22df07b6a64e39 /camera
parentbe644b94dc95c48608a5614a3de2f02d62321016 (diff)
Added rpicam-still camera frontend script.
Diffstat (limited to 'camera')
-rwxr-xr-xcamera/camera134
1 files changed, 134 insertions, 0 deletions
diff --git a/camera/camera b/camera/camera
new file mode 100755
index 0000000..f2a7329
--- /dev/null
+++ b/camera/camera
@@ -0,0 +1,134 @@
+#!/bin/sh
+
+# scripts/camera
+# rpicam-still frontend script
+#
+# supports manual mode and timelapse
+
+camera_help() {
+ echo "$0 [-t] [-i ms] [-m] [-e μs] [-f filename]"
+ echo " --timelapse"
+ echo " --interval <timelapse interval in ms>"
+ echo " --manual"
+ echo " --exposure <exposure time in μs>"
+ echo " --gain <1.0-12.0>"
+ echo " --awb <auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy, custom>"
+ echo " --filename <filename prefix>"
+}
+
+TZ="Europe/Brussels"
+export TZ
+
+# default capture settings
+AWB="daylight" # Set the AWB mode (auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy, custom)
+GAIN=1 # >=1.0 and <=8.0
+
+# default manual settings
+EXPOSURE=1000000 # astro mode exposure time in microseconds (1 s = 1,000,000 μs)
+
+# default timelapse settings
+INTERVAL=1000 # timelapse interval in milliseconds (1 s = 1,000 ms)
+
+# default output settings
+FILENAME="DT"
+SUFFIX=""
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -a|--awb)
+ shift
+ AWB="${1}"
+ if [ -z "${AWB}" ]; then
+ echo "Argument expoected: --awb <AWB mode>"
+ exit 1
+ fi
+ shift
+ ;;
+ -t|--timelapse)
+ OPTION_TIMELAPSE="yes"
+ shift
+ ;;
+ -i|--interval)
+ shift
+ INTERVAL="$1"
+ if [ -z "${INTERVAL}" ]; then
+ echo "Argument expected: --interval <timelapse interval in milliseconds>"
+ exit 1
+ fi
+ shift
+ ;;
+ -m|--manual)
+ OPTION_MANUAL="yes"
+ shift
+ ;;
+ -e|--exposure)
+ shift
+ EXPOSURE="$1"
+ if [ -z "${EXPOSURE}" ]; then
+ echo "Argument expected: --exposure <exposure time in microseconds>"
+ exit 1
+ fi
+ shift
+ ;;
+ -g|--gain)
+ shift
+ GAIN="$1"
+ if [ -z "${GAIN}" ]; then
+ echo "Argument expected: --gain <1.0-12.0>"
+ exit 1
+ fi
+ shift
+ ;;
+ -f|--filename)
+ shift
+ FILENAME="$1"
+ if [ -z "${FILENAME}" ]; then
+ echo "Argument expected: --filename <filename suffix>"
+ exit 1
+ fi
+ shift
+ ;;
+ -h|--help)
+ camera_help
+ exit 0
+ ;;
+ -*|--*)
+ echo "Unknown option $1"
+ exit 1
+ ;;
+ *)
+ echo "Unknown argument $1"
+ exit 1
+ ;;
+ esac
+done
+
+# default capture command
+CMD_CONTROL="--keypress"
+CMD_CAPTURE="--awb ${AWB} --gain ${GAIN}"
+
+# manual mode capture command
+if [[ "${OPTION_MANUAL}" = "yes" ]]; then
+ echo "Manual mode selected: gain ${GAIN} exposure ${EXPOSURE} μs"
+ SUFFIX="_GAIN${GAIN}_EXP${EXPOSURE}"
+ INTERVAL="$(($EXPOSURE/1000))"
+ CMD_CAPTURE="--shutter ${EXPOSURE} --gain ${GAIN} --awbgains 2.9,1.7 --flicker-period 0 --raw --quality 100"
+fi
+
+# timelapse options
+if [[ "${OPTION_TIMELAPSE}" = "yes" ]]; then
+ echo "Timelapse mode selected: interval ${INTERVAL} ms"
+ CMD_CONTROL="--timelapse ${INTERVAL}"
+ if [[ "${OPTION_MANUAL}" = "yes" ]]; then
+ DIRECTORY="frames/"
+ else
+ DIRECTORY="timelapse/"
+ fi
+fi
+
+exec rpicam-still \
+ --fullscreen --timeout 0 \
+ ${CMD_CONTROL} ${CMD_CAPTURE} \
+ --width 4056 --height 3040 --thumb none \
+ --encoding jpg --datetime --output ~/DCIM/${DIRECTORY}
+