-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetBestShutter.sh
executable file
·44 lines (35 loc) · 1.29 KB
/
getBestShutter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
###
### getBestShutter.sh
###
### given current aperture value, find best shutter speed (as estimated by number of unique
### colors computed by imagemagick identify
###
### AS 20190110
### READ CONFIGURATION FILE
CONFIG_FILE="config.txt"
if [ ! -f $CONFIG_FILE ]; then
echo "Configuration file not found! Exiting..."
exit 1
fi
source $CONFIG_FILE
echo "running getBestShutter.sh" >> $LOG_FILE
lastNumColors=0
# iterate through shutterspeed settings, starting with longest exposure, decreasing by 2/3 stop each time
for ((i=36;i>=0;i=i-2)); do
gphoto2 --set-config shutterspeed=$i
gphoto2 --quiet --capture-image-and-download --force-overwrite --filename $ROOT/tmp/test.jpg
# use imagemagick to get number of unique colors -- see https://imagemagick.org/script/escape.php
numColors=`identify -format %k $ROOT/tmp/test.jpg`
echo "Shutter speed setting $i has $numColors unique colors" >> $LOG_FILE
rm $ROOT/tmp/test.jpg
# test if the number of unique colors has decreased; if so, stop and use last setting
if (( $numColors < $lastNumColors )); then
break
fi
lastNumColors=$numColors
lastIdx=$i
done
echo "best shutterspeed: $lastIdx ($lastNumColors)" >> $LOG_FILE
echo $lastIdx > $ROOT/tmp/shutter
#gphoto2 --set-config shutterspeed=$lastIdx