#!/bin/bash
# Langzeitbelichtungsserie und Video mit RaspiCamV1.3
# webdav-mount: https://heinz-otto.blogspot.com/2018/01/webdav-auf-dem-raspberry.html
# sudo apt install bc
CAM="0" # Nummer der Kamera 0: 1.Kamera, 1: 2.Kamera
A="0"
TYP=""
INSTRUM="114f900_RPiCamV3"
NAME=""
TIME="2"
ANZ="20"
ERH="1"
MODUS="2304:1296:10:U" #Aufnahmemodus w:h:bits:compression
GAIN="16" #0..16
LENV="30"
RED='\033[0;31m'
NC='\033[0m' # No Color
TYPEN=("preview" "focus" "lights" "darks" "flats" "biases" "video" "copy" "delete" "quit")
cd ~/astro
DAT=$(date +"%Y_%m_%d")
mkdir $DAT
cd $DAT
rpicam-hello --list-cameras
read -e -p "Kamera: " -i "$CAM" CAM
while (true)
do
read -e -p "[0]preview video/[1]focusimages/[2]lightframes/[3]darkframes/[4]flatframes/[5]biasframes/[6]video/[c]copy files to nextcloud/[d]delete files/[u]unmount nextcloud/[q]uit: " -i "$A" A
if [ "$A" = "q" ]; then
break
fi
if [ "$A" = "c" ]; then
mount /media/nextcloud
echo "cp -a ~/astro/. /media/nextcloud/astro/"
cp -a ~/astro/. /media/nextcloud/astro/
continue
fi
if [ "$A" = "d" ]; then
echo "rm -R *"
rm -R *
continue
fi
if [ "$A" = "u" ]; then
umount /media/nextcloud
continue
fi
TYP=${TYPEN[${A}]}
read -e -p "Objektname: " -i "$NAME" NAME
mkdir $NAME
cd $NAME
if [ "$A" = "0" ]; then #preview
rpicam-hello -v 0 --camera 0 -t 0
cd ..
continue
fi
mkdir $TYP
cd $TYP
read -e -p "Gain (0..16): " -i "$GAIN" GAIN
if [ "$A" = "6" ]; then #video
read -e -p "Länge des Videos (Sekunden): " -i "$LENV" LENV
tstr=$(date +"%Y%m%d-%H%M%S")
t=$(echo "scale=0; $LENV * 1000" | bc -l)
rpicam-vid --gain $GAIN --level 4.2 --framerate 120 --width 1280 --height 720 --save-pts timestamp.pts -o $NAME-$tstr-$INSTRUM.264 -t ${LENV}s --denoise cdn_off -n
#rpicam-raw -t $t --width 1536 --height 864 -o $NAME-$tstr-$INSTRUM%05d.raw --framerate 8
continue
fi
read -e -p "Modus (w:h:bpp:compression): " -i "$MODUS" MODUS
if [ "$A" = "5" ]; then #biases
read -e -p "Zahl der Aufnahmen: " -i "$ANZ" ANZ
I=1
while [ $I -le $ANZ ]; do
echo -e "${RED}****** $TYP-frame $I/$ANZ ******${NC}"
tstr=$(date +"%Y%m%d-%H%M%S")
rpicam-still -v 0 -o bias-$tstr-$INSTRUM.jpg --shutter 0 --gain $GAIN --awbgains 1,1 --immediate --raw -n --mode $MODUS
rm "bias-$tstr-$INSTRUM.jpg"
let I=I+1
done
cd ../..
continue
fi
read -e -p "Belichtungszeit (Sekunden): " -i "$TIME" TIME
if [ "$A" = "1" ]; then #focus
echo -e "${RED}****** Mache Aufnahmen mit $TIME Sekunden zum Fokussieren ******"
echo -e "[q]uit, [+]verdopple, [-]halbiere Belichtungszeit...${NC}"
tstr=$(date +"%Y%m%d-%H%M%S")
t=$(echo "scale=0; $TIME * 1000000" | bc -l)
rpicam-still -v 0 -o focus-$tstr.jpg --shutter $t --gain $GAIN --awbgains 1,1 --raw -n --mode $MODUS
while true; do
gwenview "'focus-$tstr.jpg'" &
tstr=$(date +"%Y%m%d-%H%M%S")
t=$(echo "scale=0; $TIME * 1000000" | bc -l)
rpicam-still -v 0 -o focus-$tstr.jpg --shutter $t --gain $GAIN --awbgains 1,1 --raw -n --mode $MODUS
kill $! # Beendet das Programm
read -t 1 -n 1 key
if [ "$key" = "q" ]; then
echo "Quit"
break
elif [ "$key" = "+" ]; then
TIME=$(echo "scale=2; $TIME * 2" | bc -l)
elif [ "$key" = "-" ]; then
TIME=$(echo "scale=2; $TIME / 2" | bc -l)
fi
done
cd ../..
continue
fi
read -e -p "Instrument: " -i "$INSTRUM" INSTRUM
read -e -p "Zahl der Aufnahmen pro Belichtungszeit: " -i "$ANZ" ANZ
read -e -p "Zahl der Serien (jeweils 1.5x Zeiterhöhung): " -i "$ERH" ERH
COUNTER=1
while [ $COUNTER -le $ERH ]; do
TIME2=$(echo "scale=6; $TIME * $COUNTER" | bc -l)
I=1
while [ $I -le $ANZ ]; do
echo -e "\n\n${RED}************************* $TYP-frame $I/$ANZ von $NAME - $TIME2 Sekunden *******************************"
echo -e "[q]uit, [+]verdopple, [-]halbiere Belichtungszeit, [v]verdopple, [h]halbiere Anzahl...${NC}\n"
tstr=$(date +"%Y%m%d-%H%M%S")
t=$(echo "scale=0; $TIME2 * 1000000" | bc -l)
rpicam-still -v 0 -o $NAME-$TYP-$tstr-$TIME2-$INSTRUM.jpg --shutter $t --gain $GAIN --awbgains 1,1 --immediate --raw -n --mode $MODUS
# gwenview "'$NAME-$TYP-$tstr-$TIME2-$INSTRUM.jpg'" &
# sleep 5 # Wartet 5 Sekunden
# kill $! # Beendet das Programm
# rm "'$NAME-$TYP-$tstr-$TIME2-$INSTRUM.jpg'"
read -t 1 -n 1 key
if [ "$key" = "q" ]; then
echo "Quit"
break 2
elif [ "$key" = "+" ]; then
TIME=$(echo "scale=2; $TIME * 2" | bc -l)
TIME2=$(echo "scale=2; $TIME * $COUNTER" | bc -l)
I=0
elif [ "$key" = "-" ]; then
TIME=$(echo "scale=2; $TIME / 2" | bc -l)
TIME2=$(echo "scale=2; $TIME * $COUNTER" | bc -l)
I=0
elif [ "$key" = "v" ]; then
ANZ=$[$ANZ * 2]
elif [ "$key" = "h" ]; then
ANZ=$[$ANZ / 2]
fi
let I=I+1
done
let COUNTER=COUNTER+1
done
cd ../..
echo -e "\n${RED}******************* Fertig! *********************${NC}\n\n"
done
Neueste Kommentare