diff options
| -rwxr-xr-x | camera/camera | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/camera/camera b/camera/camera index 90cadc3..04c2d6c 100755 --- a/camera/camera +++ b/camera/camera @@ -17,9 +17,15 @@ camera_help() { echo " --exposure <exposure time in μs>" echo " --gain <1.0-12.0>" echo " --awb <auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy, custom>" + echo " --directory <directory to save images>" echo " --output <filename>" } +# Directory to save images to +# Note: direcory names with spaces might not work +DIRECTORY="~/DCIM" + +# Current tine zone TZ="Europe/Brussels" export TZ @@ -65,6 +71,19 @@ while [[ $# -gt 0 ]]; do OPTION_MANUAL="yes" shift ;; + -d|--directory) + shift + DIRECTORY="$1" + if [ -z "${DIRECTORY}" ]; then + echo "Argument expected: --directory <directory to save images>" + exit 1 + fi + if [ ! -d "${DIRECTORY}" ]; then + echo "Error: directory ${DIRECTORY} does not exist" + exit 2 + fi + shift + ;; -e|--exposure) shift EXPOSURE="$1" @@ -111,6 +130,12 @@ while [[ $# -gt 0 ]]; do esac done +# check if the output directory exists +if [ ! -d "${DIRECTORY}" ]; then + echo "Error: directory ${DIRECTORY} does not exist" + exit 2 +fi + # default capture command CMD_CONTROL="--keypress" CMD_CAPTURE="--awb ${AWB} --gain ${GAIN}" @@ -129,9 +154,9 @@ if [[ "${OPTION_TIMELAPSE}" = "yes" ]]; then echo "Timelapse mode selected: interval ${INTERVAL} ms" CMD_CONTROL="--timelapse ${INTERVAL}" if [[ "${OPTION_MANUAL}" = "yes" ]]; then - DIRECTORY="frames/" + SUBDIRECTORY="frames/" else - DIRECTORY="timelapse/" + SUBDIRECTORY="timelapse/" fi fi @@ -141,7 +166,7 @@ if [[ "${ZOOM}" = "yes" ]]; then fi CMD_EXEC+="${CMD_CONTROL} ${CMD_CAPTURE} " CMD_EXEC+="--width 4056 --height 3040 " -CMD_EXEC+="--thumb none --datetime --output /srv/smb/DCIM/${DIRECTORY}${FILENAME}_%s${SUFFIX}.jpg" +CMD_EXEC+="--thumb none --datetime --output ${DIRECTORY}/${SUBDIRECTORY}${FILENAME}_%s${SUFFIX}.jpg" echo "${CMD_EXEC}" exec ${CMD_EXEC} |
